From: Christophe JAILLET Date: Fri, 6 Aug 2021 06:46:11 +0000 (+0200) Subject: firmware: raspberrypi: Fix a leak in 'rpi_firmware_get()' X-Git-Tag: accepted/tizen/unified/20230118.172025~6526^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09cbd1df7d2615c19e40facbe31fdcb5f1ebfa96;p=platform%2Fkernel%2Flinux-rpi.git firmware: raspberrypi: Fix a leak in 'rpi_firmware_get()' The reference taken by 'of_find_device_by_node()' must be released when not needed anymore. Add the corresponding 'put_device()' in the normal and error handling paths. Fixes: 4e3d60656a72 ("ARM: bcm2835: Add the Raspberry Pi firmware driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/5e17e5409b934cd08bf6f9279c73be5c1cb11cce.1628232242.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 250e016..4b8978b 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -329,12 +329,18 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) fw = platform_get_drvdata(pdev); if (!fw) - return NULL; + goto err_put_device; if (!kref_get_unless_zero(&fw->consumers)) - return NULL; + goto err_put_device; + + put_device(&pdev->dev); return fw; + +err_put_device: + put_device(&pdev->dev); + return NULL; } EXPORT_SYMBOL_GPL(rpi_firmware_get);