Skip to content

Commit

Permalink
ieee802154: mcr20a: Fix memory leak in mcr20a_probe
Browse files Browse the repository at this point in the history
Free allocated memory for pdata before return.

Addresses-Coverity-ID: 1466096 ("Resource leak")
Fixes: 8c6ad9c ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Xue Liu <liuxuenetmail@gmail.com>
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
  • Loading branch information
Gustavo A. R. Silva authored and Stefan Schmidt committed Apr 23, 2018
1 parent aa8f877 commit 94912e8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/ieee802154/mcr20a.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,15 +1267,15 @@ 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 */
if (gpio_is_valid(pdata->rst_gpio)) {
ret = devm_gpio_request_one(&spi->dev, pdata->rst_gpio,
GPIOF_OUT_INIT_HIGH, "reset");
if (ret)
return ret;
goto free_pdata;
}

/* reset mcr20a */
Expand All @@ -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 */
Expand Down Expand Up @@ -1366,6 +1367,8 @@ mcr20a_probe(struct spi_device *spi)

free_dev:
ieee802154_free_hw(lp->hw);
free_pdata:
kfree(pdata);

return ret;
}
Expand Down

0 comments on commit 94912e8

Please sign in to comment.