Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: lpc32xx_slc: fix GPIO descriptor leak on probe error and remove

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: 6b923db2867c ("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>

authored by

Haotian Zhang and committed by
Miquel Raynal
cdf44f1a 2052c1e5

+2
+2
drivers/mtd/nand/raw/lpc32xx_slc.c
··· 937 937 dma_release_channel(host->dma_chan); 938 938 enable_wp: 939 939 lpc32xx_wp_enable(host); 940 + gpiod_put(host->wp_gpio); 940 941 941 942 return res; 942 943 } ··· 963 962 writel(tmp, SLC_CTRL(host->io_base)); 964 963 965 964 lpc32xx_wp_enable(host); 965 + gpiod_put(host->wp_gpio); 966 966 } 967 967 968 968 static int lpc32xx_nand_resume(struct platform_device *pdev)