[lkml]   [2018]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] Input: pxrc - fix leak of usb_device
Dear Marcus,

On 15.07.2018 10:42, Marcus Folkesson wrote:
> On Sat, Jul 14, 2018 at 08:51:09AM +0000, Dmitry Torokhov wrote:
>> On Sat, Jul 14, 2018 at 10:09:20AM +0200, Marcus Folkesson wrote:
>>> Hi Alexey,
>>> Good catch!
>>> On Fri, Jul 13, 2018 at 11:07:57PM +0300, Alexey Khoroshilov wrote:
>>>> pxrc_probe() calls usb_get_dev(), but there is no usb_put_dev()
>>>> anywhere in the driver.
>>>> The patch adds one to error handling code and to pxrc_isconnect().
>>>> Found by Linux Driver Verification project (
>>>> Signed-off-by: Alexey Khoroshilov <>
>>> Reviewed-by: Marcus Folkesson <>
>> Hmm, the biggest question however if we need to "take" the device, as I
>> do not think interface can outlive the device, and whether we actually
>> need to store it in pxrc, as we only need it during set up, as far as I
>> can see.
> Yep, the device is only used during setup.
> I interpret the comments for usb_get_dev() as you should take a
> reference count on the device even if you only use the interface, but I
> could be wrong.
>>From usb_get_dev()::
> * usb_get_dev - increments the reference count of the usb device structure
> * @dev: the device being referenced
> *
> * Each live reference to a device should be refcounted.
> *
> * Drivers for USB interfaces should normally record such references in
> * their probe() methods, when they bind to an interface, and release
> * them by calling usb_put_dev(), in their disconnect() methods.
> I can fix the driver to not take the device if that is what we want.
> If not Alexey want to fix it of course, it is his catch :-)

As far as I can see the proposed solution requires some refactoring of
the init code. So, I believe the author is in the better position to do

Best regards,
 \ /
  Last update: 2018-07-15 22:26    [W:0.073 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site