Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751522AbdHPHAW (ORCPT ); Wed, 16 Aug 2017 03:00:22 -0400 Received: from mga05.intel.com ([192.55.52.43]:7858 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751068AbdHPHAV (ORCPT ); Wed, 16 Aug 2017 03:00:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,381,1498546800"; d="asc'?scan'208";a="1163101539" From: Felipe Balbi To: Alexey Khoroshilov , Greg Kroah-Hartman Cc: Alexey Khoroshilov , Krzysztof Opasiak , Anton Vasilyev , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: Inconsistency in usb_add_gadget_udc_release() interface In-Reply-To: <1502833167-19354-1-git-send-email-khoroshilov@ispras.ru> References: <1502833167-19354-1-git-send-email-khoroshilov@ispras.ru> Date: Wed, 16 Aug 2017 09:59:54 +0300 Message-ID: <8760do6lqt.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1845 Lines: 55 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Alexey Khoroshilov 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=20 > 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 pa= ths? 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. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEElLzh7wn96CXwjh2IzL64meEamQYFAlmT7WoACgkQzL64meEa mQaDTg//R0f/CDhOwStlxEYyw2CVRSEmKkNJbNuzWknz++UBG6mqsc/y6ROo99Ds PNjQY5p+V2XkMGHk8/8L3YhWab2ye96lDRokp5EUr0jCe0RA7MQXyTJ4tBsVFvni ey/SzpQHf+DLvtzr4Af1cuBRjtHxLas45bpvnasIgyJO5RYiFMA/v9UeEJ/i0zJW b6Qz1kNoDoAFdK2Z3i1rkJEWRdUtgBB69INZlOb3HUSePMmeNMJRT6kbtYwpR/xE TsFFCAAZxasfi/nmDg3EfpSM7Fx1zIfMAr37HnGehwyIjQK/aZyOFDXaylqWLAc/ 3hfVS+jKC41Jhe5vQ/5USFTwN9ihSUHmDuv/2bWTwHo7nBxURXxN9RswY0scHQy2 P7jgI3eEex230PbUOFks7NmfZEY5ELlB/iCRe3ohIYwn3G4rj2udtkIwweOYm+Ms xhlN+QXI9KrF/8ZtRECLV66cidG61MFCnE/9MHo3AKwrV+eU+AYIMjiZ7dBh2NgZ zahS0OUBV6QL7hEZEzyuMoKh/+T4KMXgHKa90M6O2rnQVZYxUOHJqdshNSMwP35y 0aGPnUzmcL8MjS6cXizeuLgIWHIuMxKuSqlUcYdRLeoB2Rw1x5pa49IibPL6B7lJ ojGE1NT2SONdPcsaWe/+m8nY0gpGj231JjPzwGdRu0joT8A2cx0= =4HuG -----END PGP SIGNATURE----- --=-=-=--