Commit 6f8528e0 authored by Phong Tran's avatar Phong Tran Committed by Greg Kroah-Hartman

greybus: loopback: add more clean up when init connection fails

It should remove the object from sysfs when loopback
connection init error.
Signed-off-by: default avatarPhong Tran <tranmanphong@gmail.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 65cac604
...@@ -401,23 +401,25 @@ static int gb_loopback_connection_init(struct gb_connection *connection) ...@@ -401,23 +401,25 @@ static int gb_loopback_connection_init(struct gb_connection *connection)
connection->private = gb; connection->private = gb;
retval = sysfs_create_groups(&connection->dev.kobj, loopback_groups); retval = sysfs_create_groups(&connection->dev.kobj, loopback_groups);
if (retval) if (retval)
goto error; goto out_free;
/* Check the version */ /* Check the version */
retval = get_version(gb); retval = get_version(gb);
if (retval) if (retval)
goto error; goto out_get_ver;
gb_loopback_reset_stats(gb); gb_loopback_reset_stats(gb);
gb->task = kthread_run(gb_loopback_fn, gb, "gb_loopback"); gb->task = kthread_run(gb_loopback_fn, gb, "gb_loopback");
if (IS_ERR(gb->task)) { if (IS_ERR(gb->task)) {
retval = PTR_ERR(gb->task); retval = PTR_ERR(gb->task);
goto error; goto out_get_ver;
} }
return 0; return 0;
error: out_get_ver:
sysfs_remove_groups(&connection->dev.kobj, loopback_groups);
out_free:
kfree(gb); kfree(gb);
return retval; return retval;
} }
......
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