ieee802154: mcr20a: Fix memory leak in mcr20a_probe
PATCH 1/1 ieee802154: mcr20a: Fix memory leak in mcr20a_probe
Free allocated memory for pdata before return.
Addresses-Coverity-ID: 1466096 ("Resource leak")
--- drivers/net/ieee802154/mcr20a.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/ieee802154/mcr20a.c +6 -3
@@ -1267,7 +1267,7 @@ mcr20a_probe(struct spi_device *spi) ret =mcr20a_get_platform_data (spi, pdata);if (ret <0 ) {dev_crit (&spi->dev,"mcr20a_get_platform_data failed.\n" ); -return ret; + goto free_pdata; }/* init reset gpio */
@@ -1275,7 +1275,7 @@ mcr20a_probe(struct spi_device *spi) ret =devm_gpio_request_one (&spi->dev, pdata->rst_gpio,GPIOF_OUT_INIT_HIGH ,"reset" );if (ret) -return ret; + goto free_pdata; }/* reset mcr20a */
@@ -1291,7 +1291,8 @@ mcr20a_probe(struct spi_device *spi) hw =ieee802154_alloc_hw (sizeof (*lp), &mcr20a_hw_ops);if (!hw) {dev_crit (&spi->dev,"ieee802154_alloc_hw failed\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto free_pdata; }/* init mcr20a local data */
@@ -1366,6 +1367,8 @@ mcr20a_probe(struct spi_device *spi) free_dev:ieee802154_free_hw (lp->hw); +free_pdata: +kfree (pdata);return ret; }
Signature · 1 line
2.7.4
Hallo,
Thanks for the fix. It looks good.
Quoted 53 lines · Gustavo A. R. Silva
Free allocated memory for pdata before return.
Addresses-Coverity-ID: 1466096 ("Resource leak")
Fixes 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/net/ieee802154/mcr20a.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/net/ieee802154/mcr20a.c +6
-4@@ -1267,7 +1267,7 @@ mcr20a_probe(struct spi_device *spi) ret =mcr20a_get_platform_data (spi, pdata);if (ret <0 ) {dev_crit (&spi->dev,"mcr20a_get_platform_data failed.\n" ); -return ret; + goto free_pdata; }/* init reset gpio */ @@ -1275,7 +1275,7 @@ mcr20a_probe(struct spi_device *spi) ret =devm_gpio_request_one (&spi->dev, pdata->rst_gpio,GPIOF_OUT_INIT_HIGH ,"reset" );if (ret) -return ret; + goto free_pdata; }/* reset mcr20a */ @@ -1291,7 +1291,8 @@ mcr20a_probe(struct spi_device *spi) hw =ieee802154_alloc_hw (sizeof (*lp), &mcr20a_hw_ops);if (!hw) {dev_crit (&spi->dev,"ieee802154_alloc_hw failed\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto free_pdata; }/* init mcr20a local data */ @@ -1366,6 +1367,8 @@ mcr20a_probe(struct spi_device *spi) free_dev:ieee802154_free_hw (lp->hw); +free_pdata: +kfree (pdata);return ret; } --2.7.4
Stefan Schmidt
Acked-by Xue LiuHello.
Quoted 5 lines · Xue Liu
Hallo,
Thanks for the fix. It looks good.
ACK-by Xue Liu <[email protected]>
Thanks for the ACK Xue. The correct format would be
That way patchwork also picks the ACK up and adds it to the patch before I apply it from there.
No worries, I did this manually for you this time. For the next time please use the correct format to have this tracked.
regards
Stefan Schmidt
Hello.
Quoted 42 lines · Gustavo A. R. Silva
Free allocated memory for pdata before return.
Addresses-Coverity-ID: 1466096 ("Resource leak")
Fixes 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/net/ieee802154/mcr20a.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/net/ieee802154/mcr20a.c +4
-3@@ -1267,7 +1267,7 @@ mcr20a_probe(struct spi_device *spi) ret =mcr20a_get_platform_data (spi, pdata);if (ret <0 ) {dev_crit (&spi->dev,"mcr20a_get_platform_data failed.\n" ); -return ret; + goto free_pdata; }/* init reset gpio */ @@ -1275,7 +1275,7 @@ mcr20a_probe(struct spi_device *spi) ret =devm_gpio_request_one (&spi->dev, pdata->rst_gpio,GPIOF_OUT_INIT_HIGH ,"reset" );if (ret) -return ret; + goto free_pdata; }/* reset mcr20a */ @@ -1291,7 +1291,8 @@ mcr20a_probe(struct spi_device *spi) hw =ieee802154_alloc_hw (sizeof (*lp), &mcr20a_hw_ops);if (!hw) {dev_crit (&spi->dev,"ieee802154_alloc_hw failed\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto free_pdata; }/* init mcr20a local data */
drivers/net/ieee802154/mcr20a.c mcr20a_probe(struct spi_device *spi) · line 1374
Quoted 8 lines
drivers/net/ieee802154/mcr20a.c +2
-0@@ -1366,6 +1367,8 @@ mcr20a_probe(struct spi_device *spi) free_dev:ieee802154_free_hw (lp->hw); +free_pdata: +kfree (pdata);return ret; }
This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!
regards
Stefan Schmidt