mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-14 11:19:08 +10:00
of: dynamic: Fix use after free in of_changeset_add_prop_helper()
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: c81f6ce167
("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>
This commit is contained in:
parent
ac29e4487a
commit
80af3745ca
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user