lkml.org 
[lkml]   [2016]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 108/346] pps: do not crash when failed to register
    3.16.39-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jiri Slaby <jslaby@suse.cz>

    commit 368301f2fe4b07e5fb71dba3cc566bc59eb6705f upstream.

    With this command sequence:

    modprobe plip
    modprobe pps_parport
    rmmod pps_parport

    the partport_pps modules causes this crash:

    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: parport_detach+0x1d/0x60 [pps_parport]
    Oops: 0000 [#1] SMP
    ...
    Call Trace:
    parport_unregister_driver+0x65/0xc0 [parport]
    SyS_delete_module+0x187/0x210

    The sequence that builds up to this is:

    1) plip is loaded and takes the parport device for exclusive use:

    plip0: Parallel port at 0x378, using IRQ 7.

    2) pps_parport then fails to grab the device:

    pps_parport: parallel port PPS client
    parport0: cannot grant exclusive access for device pps_parport
    pps_parport: couldn't register with parport0

    3) rmmod of pps_parport is then killed because it tries to access
    pardev->name, but pardev (taken from port->cad) is NULL.

    So add a check for NULL in the test there too.

    Link: http://lkml.kernel.org/r/20160714115245.12651-1-jslaby@suse.cz
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Acked-by: Rodolfo Giometti <giometti@enneenne.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    drivers/pps/clients/pps_parport.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/drivers/pps/clients/pps_parport.c
    +++ b/drivers/pps/clients/pps_parport.c
    @@ -195,7 +195,7 @@ static void parport_detach(struct parpor
    struct pps_client_pp *device;

    /* FIXME: oooh, this is ugly! */
    - if (strcmp(pardev->name, KBUILD_MODNAME))
    + if (!pardev || strcmp(pardev->name, KBUILD_MODNAME))
    /* not our port */
    return;

    \
     
     \ /
      Last update: 2016-11-14 04:12    [W:4.021 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site