Skip to content

Commit f5a4950

Browse files
ISCAS-Vulabgregkh
authored andcommitted
mtd: rawnand: lpc32xx_slc: fix GPIO descriptor leak on probe error and remove
[ Upstream commit cdf44f1 ] The driver calls gpiod_get_optional() in the probe function but never calls gpiod_put() in the remove function or in the probe error path. This leads to a GPIO descriptor resource leak. The lpc32xx_mlc.c driver in the same directory handles this correctly by calling gpiod_put() on both paths. Add gpiod_put() in the remove function and in the probe error path to fix the resource leak. Fixes: 6b923db ("mtd: rawnand: lpc32xx_slc: switch to using gpiod API") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 87e02ae commit f5a4950

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/mtd/nand/raw/lpc32xx_slc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
937937
dma_release_channel(host->dma_chan);
938938
enable_wp:
939939
lpc32xx_wp_enable(host);
940+
gpiod_put(host->wp_gpio);
940941

941942
return res;
942943
}
@@ -962,6 +963,7 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
962963
writel(tmp, SLC_CTRL(host->io_base));
963964

964965
lpc32xx_wp_enable(host);
966+
gpiod_put(host->wp_gpio);
965967
}
966968

967969
static int lpc32xx_nand_resume(struct platform_device *pdev)

0 commit comments

Comments
 (0)