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

greybus: vibrator: fix memory leak in error path

Fix memory leak in connection_init error path.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 6a80ed4d
......@@ -127,7 +127,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
"vibrator%d", vib->minor);
if (IS_ERR(dev)) {
retval = -EINVAL;
goto error;
goto err_idr_remove;
}
vib->dev = dev;
......@@ -140,12 +140,14 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
retval = sysfs_create_group(&dev->kobj, vibrator_groups[0]);
if (retval) {
device_unregister(dev);
goto error;
goto err_idr_remove;
}
#endif
return 0;
err_idr_remove:
idr_remove(&minors, vib->minor);
error:
kfree(vib);
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