public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Inconsistency in usb_add_gadget_udc_release() interface
@ 2017-08-15 21:39 Alexey Khoroshilov
  2017-08-16  6:59 ` Felipe Balbi
  2017-08-16 15:24 ` Alan Stern
  0 siblings, 2 replies; 5+ messages in thread
From: Alexey Khoroshilov @ 2017-08-15 21:39 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: Alexey Khoroshilov, Krzysztof Opasiak, Anton Vasilyev, linux-usb,
	linux-kernel, ldv-project

Hello,

usb_add_gadget_udc_release() gets release() argument that allows to
release user resources.

As far as I can see, the release() is called on error paths 
of usb_add_gadget_udc_release() as a result of
put_device(&gadget->dev);
except for the only path going via err1.

As a result a caller of the usb_add_gadget_udc_release() have no chance
to know if the release() was invoked or not.

It may lead to memory leaks (drivers/usb/gadget/udc/snps_udc_core.c)
or to double free (drivers/usb/gadget/udc/fsl_udc_core.c).

Is my reading correct? If so, should we always call release() on error paths?

--
Alexey Khoroshilov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-17 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 21:39 Inconsistency in usb_add_gadget_udc_release() interface Alexey Khoroshilov
2017-08-16  6:59 ` Felipe Balbi
2017-08-16 15:24 ` Alan Stern
2017-08-16 21:15   ` Alexey Khoroshilov
2017-08-17 18:49     ` [PATCH] USB: Gadget core: fix inconsistency in the interface tousb_add_gadget_udc_release() Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox