public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>,
	Krzysztof Opasiak <k.opasiak@samsung.com>,
	Anton Vasilyev <vasilyev@ispras.ru>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: Inconsistency in usb_add_gadget_udc_release() interface
Date: Wed, 16 Aug 2017 09:59:54 +0300	[thread overview]
Message-ID: <8760do6lqt.fsf@linux.intel.com> (raw)
In-Reply-To: <1502833167-19354-1-git-send-email-khoroshilov@ispras.ru>

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]


Hi,

Alexey Khoroshilov <khoroshilov@ispras.ru> writes:
> 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?

unfortunately, it's not :-)

Note that we don't register gadget->dev until later in the code, so
there's nothing to be ->released() that early.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2017-08-16  7:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-15 21:39 Inconsistency in usb_add_gadget_udc_release() interface Alexey Khoroshilov
2017-08-16  6:59 ` Felipe Balbi [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8760do6lqt.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=k.opasiak@samsung.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=vasilyev@ispras.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox