From: Marek Vasut Date: Sat, 21 Mar 2020 17:30:46 +0100 Subject: [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path In-Reply-To: References: <20200315165843.81753-1-marek.vasut+renesas@gmail.com> <20200315165843.81753-6-marek.vasut+renesas@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 3/17/20 7:21 AM, Masahiro Yamada wrote: [...] >> @@ -283,15 +283,23 @@ int smc911x_initialize(u8 dev_num, int base_addr) >> #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) >> int retval; >> struct mii_dev *mdiodev = mdio_alloc(); >> - if (!mdiodev) >> + if (!mdiodev) { >> + eth_unregister(dev); >> + free(dev); >> return -ENOMEM; >> + } >> + >> strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); >> mdiodev->read = smc911x_miiphy_read; >> mdiodev->write = smc911x_miiphy_write; >> >> retval = mdio_register(mdiodev); >> - if (retval < 0) >> + if (retval < 0) { >> + mdio_free(mdiodev); >> + eth_unregister(dev); >> + free(dev); >> return retval; > > > Using "goto