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

greybus: interface: disable control connection on initialisation errors

Disable the control connection immediately on any errors during
interface initialisation as there's no need to keep it around for an
interface in an error state.
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 986d6911
...@@ -198,15 +198,20 @@ int gb_interface_init(struct gb_interface *intf) ...@@ -198,15 +198,20 @@ int gb_interface_init(struct gb_interface *intf)
size = gb_control_get_manifest_size_operation(intf); size = gb_control_get_manifest_size_operation(intf);
if (size <= 0) { if (size <= 0) {
dev_err(&intf->dev, "failed to get manifest size: %d\n", size); dev_err(&intf->dev, "failed to get manifest size: %d\n", size);
if (size) if (size)
return size; ret = size;
else else
return -EINVAL; ret = -EINVAL;
goto err_disable_control;
} }
manifest = kmalloc(size, GFP_KERNEL); manifest = kmalloc(size, GFP_KERNEL);
if (!manifest) if (!manifest) {
return -ENOMEM; ret = -ENOMEM;
goto err_disable_control;
}
/* Get manifest using control protocol on CPort */ /* Get manifest using control protocol on CPort */
ret = gb_control_get_manifest_operation(intf, manifest, size); ret = gb_control_get_manifest_operation(intf, manifest, size);
...@@ -242,6 +247,8 @@ int gb_interface_init(struct gb_interface *intf) ...@@ -242,6 +247,8 @@ int gb_interface_init(struct gb_interface *intf)
gb_bundle_destroy(bundle); gb_bundle_destroy(bundle);
err_free_manifest: err_free_manifest:
kfree(manifest); kfree(manifest);
err_disable_control:
gb_control_disable(intf->control);
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