On Thu, 17 May 2007, Chris Frey wrote:

> Hi,
> 
> Below is a patch with the following changes to the berry_charge.c module:
> 
> 1) kzalloc() is called, but memory is never freed
> 
>       Is this a memory leak?  I'm not sure, but the buffer is only
>       a dummy buffer to hold return data that is never used,
>       so I suspect a stack variable will suffice.

Are you aware that stack-based DMA buffers don't work on all systems?

> @@ -105,6 +128,28 @@
>       /* turn the power on */
>       magic_charge(udev);
>  
> +     /* change modes if device is a Pearl */
> +     if (udev->descriptor.idProduct == PEARL)
> +             magic_pearl(udev);
> +
> +     /* set configuration and reset to activate change */
> +     dbg(&udev->dev, "Calling set_configuration\n");
> +     retval = usb_driver_set_configuration(udev, 1);
> +     if (retval) {
> +             dev_err(&udev->dev, "Set Configuration failed :%d.\n", retval);
> +             return retval;
> +     }

Apparently you don't understand how usb_driver_set_configuration()  
works.  It doesn't set the configuration immediately; in fact the
Set-Config doesn't happen until after your driver returns.

Note that if the config you are changing to is the same as the current 
config then there's no need to use usb_driver_set_configuration().  You 
can call usb_reset_configuration() instead -- it sends a Set-Config 
request for the current configuration number.

Furthermore, if the device has changed its set of available
configurations then at some point you _must_ call usb_reset_device().  
Otherwise the kernel will be unaware of the new configs.

> +     /* reset is required by the Pearl */
> +     retval = usb_reset_configuration(udev);
> +     if (retval) {
> +             dev_err(&udev->dev, "Configuration reset failed: %d.\n", 
> retval);
> +             return retval;
> +     }

usb_reset_configuration() doesn't do a device reset; it does a 
Set-Config.  Is that what you want?  Or do you want to call 
usb_reset_device()?

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to