2014-01-04 20:08:22

by Alexey Khoroshilov

[permalink] [raw]
Subject: [PATCH] NFC: port100: fix leak of usb_device

port100_probe() calls usb_get_dev(), but there is no usb_put_dev()
in port100_disconnect(). The patch adds one.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <[email protected]>
---
drivers/nfc/port100.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
index 8a0571eb2627..a8555f81cbba 100644
--- a/drivers/nfc/port100.c
+++ b/drivers/nfc/port100.c
@@ -1509,6 +1509,7 @@ static void port100_disconnect(struct usb_interface *interface)

usb_free_urb(dev->in_urb);
usb_free_urb(dev->out_urb);
+ usb_put_dev(dev->udev);

kfree(dev->cmd);

--
1.8.3.2



2014-01-05 00:08:24

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH] NFC: port100: fix leak of usb_device

Hi Alexey,

On Sun, Jan 05, 2014 at 12:08:05AM +0400, Alexey Khoroshilov wrote:
> port100_probe() calls usb_get_dev(), but there is no usb_put_dev()
> in port100_disconnect(). The patch adds one.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <[email protected]>
> ---
> drivers/nfc/port100.c | 1 +
> 1 file changed, 1 insertion(+)
Patch applied to nfc-next, thanks.
I wonder if we really need to refcount the port100 USB interface, but
dev->in_urb does reference it for the whole driver life cycle, so I
think it all makes sense.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/