Messages in this thread | | | Date | Sun, 26 Jan 2014 22:54:16 -0800 | From | Dmitry Torokhov <> | Subject | Re: [PATCH] USB: input: gtco.c: fix usb_dev leak |
| |
Hi Alexey,
On Mon, Jan 27, 2014 at 10:31:36AM +0400, Alexey Khoroshilov wrote: > On 21.01.2014 23:59, Dmitry Torokhov wrote: > > On Sun, Jan 19, 2014 at 03:24:26AM +0400, Alexey Khoroshilov wrote: > >> There is usb_get_dev() in gtco_probe(), but there is no usb_put_dev() > >> anywhere in the driver. > >> > >> The patch adds usb_get_dev() to failure handling code of gtco_probe() > >> and to gtco_disconnect((). > > Hmm, I think gtco should simply not use usb_get_dev() in the first > > place. > > > > Thanks. > Dear Dmitry, > > Could you please clarify why usb_get_dev() not needed here? > We store reference to usb_dev in gtco structure, so we should refcount it. > What is wrong in this reasoning?
The lifetime of gtco structure is already directly tied to lifetime of usb_dev: when destroying usb_dev driver core will call remove() function of currently bound driver (in our case gtco) which will destroy gtco memory.
Taking additional reference is not needed here.
Hope this helps.
-- Dmitry
| |