Path: csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod From: Felipe Balbi Newsgroups: linux.kernel Subject: Re: [PATCH 00/16] usb: gadget: amd5536udc: fix memory leaks Date: Fri, 18 Sep 2015 20:50:02 +0200 Message-ID: References: X-Original-To: Sudip Mukherjee Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SFyWQ0h3ruR435lw" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 58 Organization: linux.* mail to news gateway X-Original-Cc: Thomas Dahlmann , Felipe Balbi , Greg Kroah-Hartman , , , X-Original-Date: Fri, 18 Sep 2015 13:39:54 -0500 X-Original-Message-ID: <20150918183954.GD7636@saruman.tx.rr.com> X-Original-References: <1442243583-24741-1-git-send-email-sudipm.mukherjee@gmail.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1228228 --SFyWQ0h3ruR435lw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 14, 2015 at 08:42:47PM +0530, Sudip Mukherjee wrote: > This amd5536udc was a complete mess. The major problems that i could > find are: >=20 > 1) if udc_pci_probe() fails in any stage then it just calls the > udc_pci_remove() to handle error. And udc_pci_remove() works with > struct udc *dev which we get from pci_get_drvdata(pdev). But we do the > pci_set_drvdata(pdev, dev) almost at the end of probe. So basically > incase of error we are handling the error by dereferencing a NULL > pointer. >=20 > 2) udc_pci_remove() does a BUG_ON(dev->driver !=3D NULL) and dev->driver > will be set only if probe is success. So that means if probe fails then > probe will call udc_pci_remove() for error handling and udc_pci_remove() > will inturn halts the kernel by calling BUG(). >=20 > And apart from these numerous memory leaks and not releasing of > resources. Here comes a rewrite of few of the functions in an > attempt to fix these. run checkpatch.pl and try again --=20 balbi --SFyWQ0h3ruR435lw Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJV/Fp6AAoJEIaOsuA1yqREBtIP/3fKnWwJMQCq6eQouxIAnNkt PnbBCKcJdiXKKozJI6WQpWnX/KUwu2JGZzpegQgQA6zFRHF3XVGuZoekA3zjSyRP LMi+tK0eI718z4nU4Zl8RgTe3sgYSWjy1ytsMUU1YNtOJvcxB6CYeX4DTAZJoxPp le0xRIvLqUC0o7YGWyrED7/SnGK68g4GgnCsrE/TW7LEd0Go5rP8qzYuK8mxNw8V eODiyZYqaTWXndrhAU+czJQbB+V4nL/GgYPI+safgTZR57rziICoZWJAG9BxGpFK OEiY2MjiGz7Y+vEd6nNohrgC1/kAHBgR0/8qlxsdIrxj1GXIOZsFW9gL5ipHi2Cz cdycRWLqpanF+ee2wbRDCpeuOX5XfUIewQ3NwQ2G1ad6rsdrnrKyqxL1NZmiLDYC FERMfW9L/VCXuIcsaYiJsU29FDN4xeh89JyVEavsDtvIePT0CIqHNSVf6ABkX08p vnf17zWhfhEKgBUyPt+TILhfgYy6NUaxowLmQUtWFuJkD64SNuzI0qLX0p0hL3Oj Uj1+WyALbwWFlMNjwkZg6yWOz/pEXGOhpSIge0cCh7IC3/7aRHbM1sCjz5sZILcn X2GZEth/HUnM7osDl+oyllBv1yLZZ+p+WyrosJG/kva6yL++heDt0p1YzH4DLHZq S4bKw1jX0ehWw7Daa0+I =e1N5 -----END PGP SIGNATURE----- --SFyWQ0h3ruR435lw-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/