ieee802154: ca8210: prevent memory leak
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Tue, 17 Sep 2019 22:47:12 +0000 (17:47 -0500)
committerStefan Schmidt <stefan@datenfreihafen.org>
Fri, 27 Sep 2019 19:57:42 +0000 (21:57 +0200)
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>
Link: https://lore.kernel.org/r/20190917224713.26371-1-navid.emamdoost@gmail.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
drivers/net/ieee802154/ca8210.c

index b188fce3f6410edf3e3a2d3f375c86cfe1b84bba..658b399ac9eacf613ce07f2631283db509d2df28 100644 (file)
@@ -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) {