diff mbox series

ieee802154: ca8210: prevent memory leak

Message ID 20190917224713.26371-1-navid.emamdoost@gmail.com (mailing list archive)
State Accepted
Headers show
Series ieee802154: ca8210: prevent memory leak | expand

Commit Message

Navid Emamdoost Sept. 17, 2019, 10:47 p.m. UTC
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.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/ieee802154/ca8210.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Schmidt Sept. 19, 2019, 2:56 p.m. UTC | #1
Hello Harry.

On 18.09.19 00:47, Navid Emamdoost wrote:
> 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.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/net/ieee802154/ca8210.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index b188fce3f641..229d70a897ca 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -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) {
> 

Could you review this patch for the ca8210 driver?

regards
Stefan Schmidt
Stefan Schmidt Sept. 27, 2019, 8:01 p.m. UTC | #2
Hello.

On 18.09.19 00:47, Navid Emamdoost wrote:
> 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.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>   drivers/net/ieee802154/ca8210.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index b188fce3f641..229d70a897ca 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -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) {
> 

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
diff mbox series

Patch

diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index b188fce3f641..229d70a897ca 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -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) {