Re: PROBLEM: BUG: null pointer dereference when using garmin USB connection with 3.6.1 kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Meanwhile, after many re-compliles:


0998d0631001288a5974afc0b2a5f568bcdecb4d is the first bad commit
commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
Author: Hans de Goede <hdegoede@xxxxxxxxxx>
Date:   Wed May 23 00:09:34 2012 +0200

    device-core: Ensure drvdata = NULL when no driver is bound

    1) drvdata is for a driver to store a pointer to driver specific data
    2) If no driver is bound, there is no driver specific data associated with
       the device
    3) Thus logically drvdata should be NULL if no driver is bound.

    But many drivers don't clear drvdata on device_release, or set drvdata
    early on in probe and leave it set on probe error. Both of which results
    in a dangling pointer in drvdata.

    This patch enforce for drvdata to be NULL after device_release or on probe
    failure.

    Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

:040000 040000 5055297c714694c0db0d62d4789c682eef6e34c7
7ef2e8ebdb41f2889ea4231b11e5ce068d505ae9 M      drivers


Alan, I'll try your patch later.

thanks,
Markus
2012/10/8 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> On Mon, 8 Oct 2012, Markus Schauler wrote:
>
>> Hi,
>>
>> my garmin device is crashing my new 3.6.1 kernel...
>> How can I help huntig the bug ?
>
> It looks like the problem is that the garmin-gps driver uses the wrong
> callbacks for creating and destroying ports.  The patch below should
> help.  Let me know how it works out.
>
> Alan Stern
>
>
>
> Index: usb-3.6/drivers/usb/serial/garmin_gps.c
> ===================================================================
> --- usb-3.6.orig/drivers/usb/serial/garmin_gps.c
> +++ usb-3.6/drivers/usb/serial/garmin_gps.c
> @@ -1405,11 +1405,10 @@ static void timeout_handler(unsigned lon
>
>
>
> -static int garmin_attach(struct usb_serial *serial)
> +static int garmin_port_probe(struct usb_serial_port *port)
>  {
> -       int status = 0;
> -       struct usb_serial_port *port = serial->port[0];
> -       struct garmin_data *garmin_data_p = NULL;
> +       int status;
> +       struct garmin_data *garmin_data_p;
>
>         garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
>         if (garmin_data_p == NULL) {
> @@ -1434,22 +1433,14 @@ static int garmin_attach(struct usb_seri
>  }
>
>
> -static void garmin_disconnect(struct usb_serial *serial)
> +static int garmin_port_remove(struct usb_serial_port *port)
>  {
> -       struct usb_serial_port *port = serial->port[0];
>         struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
>
>         usb_kill_urb(port->interrupt_in_urb);
>         del_timer_sync(&garmin_data_p->timer);
> -}
> -
> -
> -static void garmin_release(struct usb_serial *serial)
> -{
> -       struct usb_serial_port *port = serial->port[0];
> -       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
> -
>         kfree(garmin_data_p);
> +       return 0;
>  }
>
>
> @@ -1466,9 +1457,8 @@ static struct usb_serial_driver garmin_d
>         .close               = garmin_close,
>         .throttle            = garmin_throttle,
>         .unthrottle          = garmin_unthrottle,
> -       .attach              = garmin_attach,
> -       .disconnect          = garmin_disconnect,
> -       .release             = garmin_release,
> +       .port_probe             = garmin_port_probe,
> +       .port_remove            = garmin_port_remove,
>         .write               = garmin_write,
>         .write_room          = garmin_write_room,
>         .write_bulk_callback = garmin_write_bulk_callback,
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux