Commit a77660a7 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: interface: free bundles on initialisation errors

Immediately free any created bundle structures on interface
initialisation errors.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarJeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 7a137fb2
...@@ -185,6 +185,7 @@ void gb_interfaces_remove(struct gb_host_device *hd) ...@@ -185,6 +185,7 @@ void gb_interfaces_remove(struct gb_host_device *hd)
*/ */
int gb_interface_init(struct gb_interface *intf) int gb_interface_init(struct gb_interface *intf)
{ {
struct gb_bundle *bundle, *tmp;
int ret, size; int ret, size;
void *manifest; void *manifest;
...@@ -211,7 +212,7 @@ int gb_interface_init(struct gb_interface *intf) ...@@ -211,7 +212,7 @@ int gb_interface_init(struct gb_interface *intf)
ret = gb_control_get_manifest_operation(intf, manifest, size); ret = gb_control_get_manifest_operation(intf, manifest, size);
if (ret) { if (ret) {
dev_err(&intf->dev, "failed to get manifest: %d\n", ret); dev_err(&intf->dev, "failed to get manifest: %d\n", ret);
goto free_manifest; goto err_free_manifest;
} }
/* /*
...@@ -221,18 +222,25 @@ int gb_interface_init(struct gb_interface *intf) ...@@ -221,18 +222,25 @@ int gb_interface_init(struct gb_interface *intf)
if (!gb_manifest_parse(intf, manifest, size)) { if (!gb_manifest_parse(intf, manifest, size)) {
dev_err(&intf->dev, "failed to parse manifest\n"); dev_err(&intf->dev, "failed to parse manifest\n");
ret = -EINVAL; ret = -EINVAL;
goto free_manifest; goto err_destroy_bundles;
} }
ret = gb_control_get_interface_version_operation(intf); ret = gb_control_get_interface_version_operation(intf);
if (ret) if (ret)
goto free_manifest; goto err_destroy_bundles;
ret = gb_control_get_bundle_versions(intf->control); ret = gb_control_get_bundle_versions(intf->control);
if (ret) if (ret)
goto free_manifest; goto err_destroy_bundles;
kfree(manifest);
free_manifest: return 0;
err_destroy_bundles:
list_for_each_entry_safe(bundle, tmp, &intf->bundles, links)
gb_bundle_destroy(bundle);
err_free_manifest:
kfree(manifest); kfree(manifest);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment