mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 00:30:52 +07:00
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: 4e3d60656a
("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>
This commit is contained in:
parent
037af66fba
commit
c38f5e4c9a
@ -322,12 +322,18 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node)
|
|||||||
|
|
||||||
fw = platform_get_drvdata(pdev);
|
fw = platform_get_drvdata(pdev);
|
||||||
if (!fw)
|
if (!fw)
|
||||||
return NULL;
|
goto err_put_device;
|
||||||
|
|
||||||
if (!kref_get_unless_zero(&fw->consumers))
|
if (!kref_get_unless_zero(&fw->consumers))
|
||||||
return NULL;
|
goto err_put_device;
|
||||||
|
|
||||||
|
put_device(&pdev->dev);
|
||||||
|
|
||||||
return fw;
|
return fw;
|
||||||
|
|
||||||
|
err_put_device:
|
||||||
|
put_device(&pdev->dev);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rpi_firmware_get);
|
EXPORT_SYMBOL_GPL(rpi_firmware_get);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user