Skip to content

Commit d788007

Browse files
tititiou36smb49
authored andcommitted
firmware: raspberrypi: Fix a leak in 'rpi_firmware_get()'
BugLink: https://bugs.launchpad.net/bugs/1946788 [ Upstream commit 09cbd1d ] 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: 4e3d606 ("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> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
1 parent 24feb5e commit d788007

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/firmware/raspberrypi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,18 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
322322

323323
fw = platform_get_drvdata(pdev);
324324
if (!fw)
325-
return NULL;
325+
goto err_put_device;
326326

327327
if (!kref_get_unless_zero(&fw->consumers))
328-
return NULL;
328+
goto err_put_device;
329+
330+
put_device(&pdev->dev);
329331

330332
return fw;
333+
334+
err_put_device:
335+
put_device(&pdev->dev);
336+
return NULL;
331337
}
332338
EXPORT_SYMBOL_GPL(rpi_firmware_get);
333339

0 commit comments

Comments
 (0)