diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-03-09 12:20:37 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-03-10 13:57:42 -0800 |
commit | a77660a75a3f79c71064dc6848a2975731ca5c00 (patch) | |
tree | 8fc014813ec3cf139193970181441756e7fadc56 /drivers/staging/greybus/interface.c | |
parent | 7a137fb290df63f24242fc4996decd0b339ba3b1 (diff) | |
download | op-kernel-dev-a77660a75a3f79c71064dc6848a2975731ca5c00.zip op-kernel-dev-a77660a75a3f79c71064dc6848a2975731ca5c00.tar.gz |
greybus: interface: free bundles on initialisation errors
Immediately free any created bundle structures on interface
initialisation errors.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/interface.c')
-rw-r--r-- | drivers/staging/greybus/interface.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index a32e564..fe4efe1 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -185,6 +185,7 @@ void gb_interfaces_remove(struct gb_host_device *hd) */ int gb_interface_init(struct gb_interface *intf) { + struct gb_bundle *bundle, *tmp; int ret, size; void *manifest; @@ -211,7 +212,7 @@ int gb_interface_init(struct gb_interface *intf) ret = gb_control_get_manifest_operation(intf, manifest, size); if (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) if (!gb_manifest_parse(intf, manifest, size)) { dev_err(&intf->dev, "failed to parse manifest\n"); ret = -EINVAL; - goto free_manifest; + goto err_destroy_bundles; } ret = gb_control_get_interface_version_operation(intf); if (ret) - goto free_manifest; + goto err_destroy_bundles; ret = gb_control_get_bundle_versions(intf->control); 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); return ret; |