Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp315218imm; Thu, 26 Jul 2018 04:12:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLv8e7MhHW2/G0j4yDKojAlU9qy1KlXE0OEwc88ribv0bVnjkRlS8l+RkO9ptfsbLm2pYI X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr1492634pgv.79.1532603552552; Thu, 26 Jul 2018 04:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532603552; cv=none; d=google.com; s=arc-20160816; b=0T4cJfzx7wAlou+bPITRM0qspr2f+RFM1tkEZPrTAHEtk1wij75CossRDRzD+jgaO5 bw8UI8e9FyvkbbhV68HrpAdWWkzM9+PMMuN6cD9UeFhTNroZXZiKFxkFN1V2w4DnIOnR RipJ3evIwjVkeCV+NmKqVDXlRfmt4/4xkEpggmQr6Ea8GKhzrMR4ORhJn0DMpz421pM4 fwrxGxVFrO5lhKudH5NWNodWQKGqXKjXceUI4ycPXbCYvDB/v7brNk37KSvu/J1MxTIN oifPuM2AXJElQ141m5cZOyfPNcRZnf0tO0Bf3TPZ6BwaaAkUptpiwMymlyzpt0pofa2c vthg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=aLPy8/RMGRHJK7FUrliiAxL65g5TED01d9B8nk8aGQM=; b=WJyzbTiSORoyyqJQ20lxQfOd1nC0FAiXuN68W+nTziuv9kr+VVtOePgcGpzrEhO8y3 WCWMTpw3eJYiLxoqWB5otOyAsTrgX9HTn8TJNbWJSdkaqHCbwhhyJMqf7Y2Dzd4BIqwn Uo9MXvX+o4l1YAD7+/0HtVv3gMSmGUtNuu/wu3agdmnyKJYTgluqsUGN0kExw/g4scQw 3hLmlrBRStwNu2fRW1M+LbQVRfPxHWVeZTxKr/F7kiXCI886BWX9LMKscOlnsXL9zcID bHE/itSbLFtlqt1u6BzHVjZ/KMRYvCYizP3Up6XF/rIH7Y7eEW7kb1Md/MiJj+07Jhjx xaLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64-v6si1266579pfb.314.2018.07.26.04.12.17; Thu, 26 Jul 2018 04:12:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729314AbeGZM1u (ORCPT + 99 others); Thu, 26 Jul 2018 08:27:50 -0400 Received: from mga11.intel.com ([192.55.52.93]:56332 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729031AbeGZM1u (ORCPT ); Thu, 26 Jul 2018 08:27:50 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 04:11:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,404,1526367600"; d="asc'?scan'208";a="248536824" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.68.37]) by fmsmga005.fm.intel.com with ESMTP; 26 Jul 2018 04:11:26 -0700 From: Felipe Balbi To: Xidong Wang , Greg Kroah-Hartman , Johan Hovold , Michal Nazarewicz , Vincent Pelletier Cc: wangxidong_97@163.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] usb:gadget:function:fix memory leak In-Reply-To: <1532344186-30505-1-git-send-email-wangxidong_97@163.com> References: <1532344186-30505-1-git-send-email-wangxidong_97@163.com> Date: Thu, 26 Jul 2018 14:08:09 +0300 Message-ID: <87fu061ch2.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable hi, Xidong Wang writes: > In function f_audio_set_alt(), the memory allocated by > usb_ep_alloc_request() is not released on the error path > that req->buf, which holds the return value of kzalloc(), > is NULL. This will result in a memory leak bug. > > Signed-off-by: Xidong Wang > --- > drivers/usb/gadget/function/f_uac1_legacy.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/f_uac1_legacy.c b/drivers/usb/ga= dget/function/f_uac1_legacy.c > index 24c086b..2fcdade 100644 > --- a/drivers/usb/gadget/function/f_uac1_legacy.c > +++ b/drivers/usb/gadget/function/f_uac1_legacy.c > @@ -630,8 +630,11 @@ static int f_audio_set_alt(struct usb_function *f, u= nsigned intf, unsigned alt) > ERROR(cdev, > "%s queue req: %d\n", > out_ep->name, err); > - } else > + } else { > + usb_ep_free_request( > + out_ep, req); > err =3D -ENOMEM; > + } I feel like this hunk has been ping ponging between having usb_ep_free_request() and not having it because completion callback will call usb_ep_free_request() or something along those lines. Can we get a final solution that solves all cases and doesn't introduce other bugs? =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEElLzh7wn96CXwjh2IzL64meEamQYFAltZq5kACgkQzL64meEa mQbMPQ/+JMoKRBXYMh8ZQdgYRUkYM47HJzhCxgg6cOkGTLLmv73INF7e3m38kK5C bE9/LJLHzLZtuJs2mG2WbPHWEVQC1JXjTwm9frroz+XwNk1Jm1ZbN+d2Hio6TZQd GA0mkoavUnfdO+MQipG394KNnb4qdbRgfyY/eGRJm+Pqf0OzFcXKR0wZSyEzWpmU Zb18eRIr+TeD1R3O0JrXtrl2iGds7Ue9EdCVtj90Yu/Lsx/SMb+tmp8wL6235Vvs I74quqH2YqU8KKxRZW0Mc5F7r1WNjxMOEjNN1OKL/LikdL0RzhaJE4lmqmezQBp2 xiOceBJPzGVqLB8X9svPVX02UZocimr92/fIB9FTjN/cmkg3IiyMz0GqNSODtufF 89iENMIk9bCuuxTOM/zERbvYDA0m0UEV/QhjZxVCSOn/BaRAf4IsIUEVyzUNhq0V f6f7Yw4aLjXa0m+2HG5Bcu1rH18JH1WMgHi1ltLUYucnWXvM3W5sOztKXMhouDRm wax2HMdMmVxQeawNES0+KTMBbwtntmmD8GgLSK7w4gg/ciQxWTC4c83N21taPP8Q CWlKcXefuwT1HTErT83l6O/uhriNGjoym0xutO49F4ilBu/TtX/AR1xBkkVNagg6 lXxjKatFDpdsVXKfJOyNCro6kKxzqaBop45z6YpFbz3hLcUq4iE= =DHiW -----END PGP SIGNATURE----- --=-=-=--