summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2021-08-06 08:46:11 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-15 09:50:41 +0200
commitb2f4dd13b211691715e99e28fff9ce9557acc57c (patch)
treebe898b2b331abd75c8d4c0fa0f8e06fc409d9672
parent60831f5ae6c713afceb6d29f40899ed112f36059 (diff)
downloadlinux-stable-b2f4dd13b211691715e99e28fff9ce9557acc57c.tar.gz
linux-stable-b2f4dd13b211691715e99e28fff9ce9557acc57c.tar.bz2
linux-stable-b2f4dd13b211691715e99e28fff9ce9557acc57c.zip
firmware: raspberrypi: Fix a leak in 'rpi_firmware_get()'
[ Upstream commit 09cbd1df7d2615c19e40facbe31fdcb5f1ebfa96 ] 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 <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/5e17e5409b934cd08bf6f9279c73be5c1cb11cce.1628232242.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/firmware/raspberrypi.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 8996deadd79b..1d965c1252ca 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -322,12 +322,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);