]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ieee802154: mcr20a: do not leak resources on error path
authorStefan Schmidt <stefan@osg.samsung.com>
Thu, 12 Apr 2018 12:28:49 +0000 (14:28 +0200)
committerStefan Schmidt <stefan@osg.samsung.com>
Mon, 23 Apr 2018 18:56:23 +0000 (20:56 +0200)
We already allocated the device and platform  data at this
point. Instead of simply return from the probe function we
need to cleanup the resources first.

Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
Acked-by: Xue Liu <liuxuenetmail@gmail.com>
drivers/net/ieee802154/mcr20a.c

index 944470d69ba9a35c19916407b0c236c02ea0a732..de0d7f28a181ca4acb1da2131d82a981627a8e96 100644 (file)
@@ -1309,8 +1309,10 @@ mcr20a_probe(struct spi_device *spi)
        /* init buf */
        lp->buf = devm_kzalloc(&spi->dev, SPI_COMMAND_BUFFER, GFP_KERNEL);
 
-       if (!lp->buf)
-               return -ENOMEM;
+       if (!lp->buf) {
+               ret = -ENOMEM;
+               goto free_dev;
+       }
 
        mcr20a_setup_tx_spi_messages(lp);
        mcr20a_setup_rx_spi_messages(lp);