浏览代码

net: ieee802154: mcr20a: do not leak resources on error path

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>
Stefan Schmidt 7 年之前
父节点
当前提交
7e0ffee1b2
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      drivers/net/ieee802154/mcr20a.c

+ 4 - 2
drivers/net/ieee802154/mcr20a.c

@@ -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);