greybus: connection: silence warning on unbound protocols
authorPerry Hung <perry@leaflabs.com>
Fri, 24 Jul 2015 23:02:30 +0000 (19:02 -0400)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 24 Jul 2015 23:39:58 +0000 (16:39 -0700)
If a protocol was not successfully created, we can't drop the refcount
on it. This might happen for example if the connection fails to bind a
protocol.

Silences a warning on cleanup.

Signed-off-by: Perry Hung <perry@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/protocol.c

index 0cd716d58a3aa854120f2f4e6196ed0f046e0e4d..c57deb2053ac58be1ce0bf26a053d2fb76da5466 100644 (file)
@@ -319,7 +319,8 @@ void gb_connection_destroy(struct gb_connection *connection)
        list_del(&connection->hd_links);
        spin_unlock_irq(&gb_connections_lock);
 
-       gb_protocol_put(connection->protocol);
+       if (connection->protocol)
+               gb_protocol_put(connection->protocol);
        connection->protocol = NULL;
 
        id_map = &connection->hd->cport_id_map;
index 6aebbbd585e1681d33280dbd5a179e9cf0d78868..06b4841173ce1c0693bda65130af1c6a77ea13d7 100644 (file)
@@ -196,9 +196,6 @@ void gb_protocol_put(struct gb_protocol *protocol)
        u8 minor;
        u8 protocol_count;
 
-       if (WARN_ON(!protocol))
-               return;
-
        id = protocol->id;
        major = protocol->major;
        minor = protocol->minor;