summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2025-08-22 11:08:46 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-09-04 15:31:43 +0200
commit0d3471ab7186cf468898fe12972aa16452f274c0 (patch)
tree7e0d06356229e3af54e2ff396c7f447e2c4c10ba
parent76c872066d75f86f8d8a5def681da2aee811fc62 (diff)
of: dynamic: Fix use after free in of_changeset_add_prop_helper()
[ Upstream commit 80af3745ca465c6c47e833c1902004a7fa944f37 ] If the of_changeset_add_property() function call fails, then this code frees "new_pp" and then dereference it on the next line. Return the error code directly instead. Fixes: c81f6ce16785 ("of: dynamic: Fix memleak when of_pci_add_properties() failed") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/aKgljjhnpa4lVpdx@stanley.mountain Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/of/dynamic.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index fcaaadc2eca1..492f0354a792 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -935,13 +935,15 @@ static int of_changeset_add_prop_helper(struct of_changeset *ocs,
return -ENOMEM;
ret = of_changeset_add_property(ocs, np, new_pp);
- if (ret)
+ if (ret) {
__of_prop_free(new_pp);
+ return ret;
+ }
new_pp->next = np->deadprops;
np->deadprops = new_pp;
- return ret;
+ return 0;
}
/**