mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 11:03:07 -04:00
soc: samsung: exynos-pmu: fix of_node refcount leak in exynos_get_pmu_regmap()
exynos_get_pmu_regmap() obtains a device_node via of_find_matching_node()
and passes it to exynos_get_pmu_regmap_by_phandle(np, NULL). With
propname == NULL the callee uses np directly and does not drop a
reference, so the reference taken by of_find_matching_node() is leaked on
every call -- including on each -EPROBE_DEFER retry of the only in-tree
caller, exynos_retention_init() in the Exynos pinctrl driver.
Annotate np with the __free(device_node) cleanup attribute so the
reference is released when the function returns.
Found by static analysis tool CodeQL.
Fixes: 76640b84bd ("soc: samsung: pmu: Provide global function to get PMU regmap")
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Link: https://patch.msgid.link/20260609143852.1783558-1-geoffreyhe2@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
This commit is contained in:
committed by
Krzysztof Kozlowski
parent
dc59e4fea9
commit
fa476d53ed
@@ -167,8 +167,8 @@ static const struct mfd_cell exynos_pmu_devs[] = {
|
||||
*/
|
||||
struct regmap *exynos_get_pmu_regmap(void)
|
||||
{
|
||||
struct device_node *np = of_find_matching_node(NULL,
|
||||
exynos_pmu_of_device_ids);
|
||||
struct device_node *np __free(device_node) =
|
||||
of_find_matching_node(NULL, exynos_pmu_of_device_ids);
|
||||
if (np)
|
||||
return exynos_get_pmu_regmap_by_phandle(np, NULL);
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
Reference in New Issue
Block a user