diff options
author | Fabien Parent <fparent@baylibre.com> | 2015-10-13 17:34:51 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-10-14 11:54:51 -0700 |
commit | 67b81757dad8979e0cd85512fc0e5dfe80e2e96f (patch) | |
tree | 6ff6d0bfe735fcb583164f121bf9ba3391501d4e /drivers/staging/greybus/connection.c | |
parent | 82ee1e6cde3d9500f3dfc9cefc259b89e87a8865 (diff) | |
download | linux-stable-67b81757dad8979e0cd85512fc0e5dfe80e2e96f.tar.gz linux-stable-67b81757dad8979e0cd85512fc0e5dfe80e2e96f.tar.bz2 linux-stable-67b81757dad8979e0cd85512fc0e5dfe80e2e96f.zip |
greybus: connection: destroy connection on failing to bind it
gb_connection_bind_protocol() returns proper error codes now and we
should destroy the connection on failures.
This change also fixes a NULL deref on hotplug when the control connection fails
to initialize.
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/connection.c')
-rw-r--r-- | drivers/staging/greybus/connection.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 6b56b3069fae..bd3f83b2ccb6 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -239,7 +239,14 @@ gb_connection_create_range(struct greybus_host_device *hd, spin_unlock_irq(&gb_connections_lock); - gb_connection_bind_protocol(connection); + retval = gb_connection_bind_protocol(connection); + if (retval) { + dev_err(&connection->dev, "failed to bind protocol: %d\n", + retval); + gb_connection_destroy(connection); + return NULL; + } + if (!connection->protocol) dev_warn(&connection->dev, "protocol 0x%02hhx handler not found\n", protocol_id); |