summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/connection.c
diff options
context:
space:
mode:
authorJohan Hovold2015-07-23 10:50:01 +0200
committerGreg Kroah-Hartman2015-07-23 21:55:25 +0200
commit10f9fa133a295fa0f2f36c1a481b7e8b82b12891 (patch)
tree2ab822e8ef27fc955ad12de03e0189cb9c93d306 /drivers/staging/greybus/connection.c
parentgreybus: connection: clean up connection creation (diff)
downloadkernel-qcow2-linux-10f9fa133a295fa0f2f36c1a481b7e8b82b12891.tar.gz
kernel-qcow2-linux-10f9fa133a295fa0f2f36c1a481b7e8b82b12891.tar.xz
kernel-qcow2-linux-10f9fa133a295fa0f2f36c1a481b7e8b82b12891.zip
greybus: connection: clean up creation error paths
Clean up connection-creation error paths. Tested-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r--drivers/staging/greybus/connection.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 1820676343de..555625c3fcef 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -167,15 +167,14 @@ gb_connection_create_range(struct greybus_host_device *hd,
return NULL;
}
+ hd_cport_id = ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL);
+ if (hd_cport_id < 0)
+ return NULL;
+
connection = kzalloc(sizeof(*connection), GFP_KERNEL);
if (!connection)
- return NULL;
+ goto err_remove_ida;
- hd_cport_id = ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL);
- if (hd_cport_id < 0) {
- kfree(connection);
- return NULL;
- }
connection->hd_cport_id = hd_cport_id;
connection->intf_cport_id = cport_id;
connection->hd = hd;
@@ -201,14 +200,13 @@ gb_connection_create_range(struct greybus_host_device *hd,
retval = device_add(&connection->dev);
if (retval) {
- ida_simple_remove(id_map, connection->hd_cport_id);
connection->hd_cport_id = CPORT_ID_BAD;
put_device(&connection->dev);
pr_err("failed to add connection device for cport 0x%04hx\n",
cport_id);
- return NULL;
+ goto err_remove_ida;
}
spin_lock_irq(&gb_connections_lock);
@@ -228,6 +226,11 @@ gb_connection_create_range(struct greybus_host_device *hd,
"protocol 0x%02hhx handler not found\n", protocol_id);
return connection;
+
+err_remove_ida:
+ ida_simple_remove(id_map, hd_cport_id);
+
+ return NULL;
}
struct gb_connection *gb_connection_create(struct gb_bundle *bundle,