Skip to contentSkip to conversation

ieee802154: ca8210: prevent memory leak

PATCH In review Navid Emamdoost 2 participants 3 messages Sep 17, 2019 – Sep 27, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee802154: ca8210: prevent memory leak

In ca8210_probe the allocated pdata needs to be assigned to spi_device->dev.platform_data before calling ca8210_get_platform_data. Othrwise when ca8210_get_platform_data fails pdata cannot be released.

---
 drivers/net/ieee802154/ca8210.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +1 -1
index b188fce3f641..229d70a897ca 100644
@@ -3152,12 +3152,12 @@ static int ca8210_probe(struct spi_device *spi_device)
 		goto error;
 	}
 
+	priv->spi->dev.platform_data = pdata;
 	ret = ca8210_get_platform_data(priv->spi, pdata);
 	if (ret) {
 		dev_crit(&spi_device->dev, "ca8210_get_platform_data failed\n");
 		goto error;
 	}
-	priv->spi->dev.platform_data = pdata;
 
 	ret = ca8210_dev_com_init(priv);
 	if (ret) {
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Hello Harry.

Quoted 18 lines · Navid Emamdoost

In ca8210_probe the allocated pdata needs to be assigned to spi_device->dev.platform_data before calling ca8210_get_platform_data. Othrwise when ca8210_get_platform_data fails pdata cannot be released.

---
 drivers/net/ieee802154/ca8210.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +0 -0
index b188fce3f641..229d70a897ca 100644
@@ -3152,12 +3152,12 @@ static int ca8210_probe(struct spi_device *spi_device)
 		goto error;
 	}
 

drivers/net/ieee802154/ca8210.c static int ca8210_probe(struct spi_device *spi_device) · line 3163

Quoted 10 lines
drivers/net/ieee802154/ca8210.c +1 -1
+	priv->spi->dev.platform_data = pdata;
 	ret = ca8210_get_platform_data(priv->spi, pdata);
 	if (ret) {
 		dev_crit(&spi_device->dev, "ca8210_get_platform_data failed\n");
 		goto error;
 	}
-	priv->spi->dev.platform_data = pdata;
 
 	ret = ca8210_dev_com_init(priv);
 	if (ret) {

Could you review this patch for the ca8210 driver?

regards
Stefan Schmidt

maintainer
#2 lore raw
In reply to Navid Emamdoost

Hello.

Quoted 18 lines · Navid Emamdoost

In ca8210_probe the allocated pdata needs to be assigned to spi_device->dev.platform_data before calling ca8210_get_platform_data. Othrwise when ca8210_get_platform_data fails pdata cannot be released.

---
  drivers/net/ieee802154/ca8210.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +0 -0
index b188fce3f641..229d70a897ca 100644
@@ -3152,12 +3152,12 @@ static int ca8210_probe(struct spi_device *spi_device)
  		goto error;
  	}
 

drivers/net/ieee802154/ca8210.c static int ca8210_probe(struct spi_device *spi_device) · line 3163

Quoted 10 lines
drivers/net/ieee802154/ca8210.c +1 -1
+	priv->spi->dev.platform_data = pdata;
  	ret = ca8210_get_platform_data(priv->spi, pdata);
  	if (ret) {
  		dev_crit(&spi_device->dev, "ca8210_get_platform_data failed\n");
  		goto error;
  	}
-	priv->spi->dev.platform_data = pdata;
 
  	ret = ca8210_dev_com_init(priv);
  	if (ret) {

As Harry seems to be unavailable I am taking this patch directly.

This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt