Coverity: Fix CID1393979

Fix resource leak in dt_set_bin_prop_by_path().

Change-Id: I1c4d7e01b25847a2091ad90d2d70711beae55905
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/27445
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
Patrick Rudolph 2018-07-11 13:53:04 +02:00 committed by Philipp Deppenwiese
parent 3ec008bf40
commit 679d624fae
1 changed files with 3 additions and 0 deletions

View File

@ -944,6 +944,7 @@ int dt_set_bin_prop_by_path(struct device_tree *tree, const char *path,
prop_name = strrchr(path_copy, '/');
if (!prop_name) {
free(path_copy);
printk(BIOS_ERR, "Path %s does not include '/'\n", path);
return 1;
}
@ -956,10 +957,12 @@ int dt_set_bin_prop_by_path(struct device_tree *tree, const char *path,
if (!dt_node) {
printk(BIOS_ERR, "Failed to %s %s in the device tree\n",
create ? "create" : "find", path_copy);
free(path_copy);
return 1;
}
dt_add_bin_prop(dt_node, prop_name, data, data_size);
free(path_copy);
return 0;
}