From: Jan Kiszka <[email protected]> When some of_changeset_add/update_property fails, the property needs to be freed. Do this unconditionally in the common error path, just ensuring that prop is always initialized and, when consumed, set to NULL or the next value. The latter is already the case, we only need to NULL prop after the finaly of_changeset_update_property.
Signed-off-by: Jan Kiszka <[email protected]> --- driver/pci.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/driver/pci.c b/driver/pci.c index f4fee561..bc02629d 100644 --- a/driver/pci.c +++ b/driver/pci.c @@ -254,6 +254,9 @@ static struct device_node *overlay; static void free_prop(struct property *prop) { + if (!prop) + return; + kfree(prop->name); kfree(prop->value); kfree(prop); @@ -421,13 +424,17 @@ static bool create_vpci_of_overlay(struct jailhouse_system *config) strcpy(prop->value, "ok"); if (of_changeset_update_property(&overlay_changeset, vpci_node, - prop) < 0 || - of_changeset_apply(&overlay_changeset) < 0) + prop) < 0) + goto out; + prop = NULL; + + if (of_changeset_apply(&overlay_changeset) < 0) goto out; overlay_applied = true; out: + free_prop(prop); of_node_put(vpci_node); if (!overlay_applied) { struct of_changeset_entry *ce; -- 2.16.4 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/1b480b7c2eae1bd1b898e0df379c3fef1edd4337.1562179456.git.jan.kiszka%40siemens.com. For more options, visit https://groups.google.com/d/optout.
