Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932855AbcDLI23 (ORCPT ); Tue, 12 Apr 2016 04:28:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:10694 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932251AbcDLI21 (ORCPT ); Tue, 12 Apr 2016 04:28:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,473,1455004800"; d="asc'?scan'208";a="943321360" From: Felipe Balbi To: changbin.du@intel.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Du\, Changbin" Subject: Re: [PATCH v2] usb: dwc3: fix memory leak of dwc->regset In-Reply-To: <1460448883-25337-1-git-send-email-changbin.du@intel.com> References: <877fg3mjti.fsf@intel.com> <1460448883-25337-1-git-send-email-changbin.du@intel.com> User-Agent: Notmuch/0.21+96~g9bbc54b (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Tue, 12 Apr 2016 11:26:29 +0300 Message-ID: <87k2k3kzbe.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1930 Lines: 66 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, changbin.du@intel.com writes: > From: "Du, Changbin" > > dwc->regset is allocated on dwc3_debugfs_init, and should > be released on init failure or dwc3_debugfs_exit. Btw, > The line "dwc->root =3D NULL" is unnecessary, so remove it. > > Signed-off-by: Du, Changbin > --- > v2: > Title changed; > free dwc->regset on failure path. > > --- > drivers/usb/dwc3/debugfs.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c > index 9ac37fe..abd8889 100644 > --- a/drivers/usb/dwc3/debugfs.c > +++ b/drivers/usb/dwc3/debugfs.c > @@ -678,7 +678,8 @@ int dwc3_debugfs_init(struct dwc3 *dwc) >=20=20 > err1: > debugfs_remove_recursive(root); > - > + if (!dwc->regset) > + kfree(dwc->regset); IOW: if regset is NULL, free NULL. This check is wrong and unnecessary ;-) kfree(NULL) is safe. =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXDLE1AAoJEIaOsuA1yqREOmQP/2SnmtuGBltq34HTh7IUyE7V HVUBsCgHdQf1dtSOo2I63RuRESF6xJZs9a/fdrXw6lv3lvIEwNZtn4WBedqUVsmP EFEBkow8xPMGYMtHL8u3c3oX3oJqbd0gLeEDV1CFkUQlGcDt5MeJGOd/7kaqlTum lJbg9e/B3E69BNMjOQ8xNS4ywXL2LlVtEYTFkYTtIvf4XuL3RZwfA4W5qZ4KwXzq hLqpuQwplWTBvQF1CYMc97SCh7+ukyVvR8wbgnt+PpJewWw9B/JwO6+e/rQfeuK+ z0PNQRz7EFUErzez6JP0tUWVlPB1/Ipcq815dF87X1QrOz/2Q2EcvKPqm29HE1BV 4O9TB0H3CgY4qXQ1jYrLnSdRHWu2knznLbG0ctswpCPqV7Ng4xGD/J4P+wLSXmHJ cCNv8vR58AjIyC3wYGhBXXCpcKbgK9Z/Y4vg+uD/7BJ7L6TS++VZG0DnpOQKIGbe QknqDoQd5U6OtuT0QYmpcBtF3X4/uKA27+znfUUtpeL51+O+7b7GYeBoTJXeXTE7 gG0FpI+ptTyybz/aAScpiu5aTEtgSWsd/ikdIUll1jEo+y104/RDH9yzmIprzbFz WR1/YiWMSbq8+i0Skl5Mv1oQOU5sBq5//o0k7ZH3Q6JP7+fo+uruOf38I7tKowua khdasoh1IDbgh8KUepMM =S6nK -----END PGP SIGNATURE----- --=-=-=--