* [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe
@ 2018-04-05 16:20 Gustavo A. R. Silva
2018-04-10 9:54 ` Xue Liu
2018-04-10 10:58 ` Stefan Schmidt
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-05 16:20 UTC (permalink / raw)
To: Xue Liu, Alexander Aring, Stefan Schmidt
Cc: linux-wpan, netdev, linux-kernel, 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 <gustavo@embeddedor.com>
---
drivers/net/ieee802154/mcr20a.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index 55a22c7..944470d 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe
2018-04-05 16:20 [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe Gustavo A. R. Silva
@ 2018-04-10 9:54 ` Xue Liu
2018-04-10 10:26 ` Stefan Schmidt
2018-04-10 10:58 ` Stefan Schmidt
1 sibling, 1 reply; 4+ messages in thread
From: Xue Liu @ 2018-04-10 9:54 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Alexander Aring, Stefan Schmidt, linux-wpan - ML, netdev, linux-kernel
Hallo,
Thanks for the fix. It looks good.
ACK-by: Xue Liu <liuxuenetmail@gmail.com>
On 5 April 2018 at 18:20, Gustavo A. R. Silva <gustavo@embeddedor.com> wrote:
> 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 <gustavo@embeddedor.com>
> ---
> drivers/net/ieee802154/mcr20a.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index 55a22c7..944470d 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe
2018-04-10 9:54 ` Xue Liu
@ 2018-04-10 10:26 ` Stefan Schmidt
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2018-04-10 10:26 UTC (permalink / raw)
To: Xue Liu, Gustavo A. R. Silva
Cc: Alexander Aring, linux-wpan - ML, netdev, linux-kernel
Hello.
On 04/10/2018 11:54 AM, Xue Liu wrote:
> Hallo,
>
> Thanks for the fix. It looks good.
>
> ACK-by: Xue Liu <liuxuenetmail@gmail.com>
Thanks for the ACK Xue. The correct format would be
Acked-by: Xue Liu <liuxuenetmail@gmail.com>
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe
2018-04-05 16:20 [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe Gustavo A. R. Silva
2018-04-10 9:54 ` Xue Liu
@ 2018-04-10 10:58 ` Stefan Schmidt
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2018-04-10 10:58 UTC (permalink / raw)
To: Gustavo A. R. Silva, Xue Liu, Alexander Aring
Cc: linux-wpan, netdev, linux-kernel
Hello.
On 04/05/2018 06:20 PM, Gustavo A. R. Silva wrote:
> 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 <gustavo@embeddedor.com>
> ---
> drivers/net/ieee802154/mcr20a.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
> index 55a22c7..944470d 100644
> --- a/drivers/net/ieee802154/mcr20a.c
> +++ b/drivers/net/ieee802154/mcr20a.c
> @@ -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;
> }
This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!
regards
Stefan Schmidt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-10 10:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05 16:20 [PATCH] ieee802154: mcr20a: Fix memory leak in mcr20a_probe Gustavo A. R. Silva
2018-04-10 9:54 ` Xue Liu
2018-04-10 10:26 ` Stefan Schmidt
2018-04-10 10:58 ` Stefan Schmidt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.