diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index bf5fa101e541..abd74116cf62 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -195,7 +195,6 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle, connection->major = major; connection->minor = minor; if (!gb_connection_hd_cport_id_alloc(connection)) { - gb_protocol_put(connection->protocol); kfree(connection); return NULL; } @@ -217,7 +216,6 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle, pr_err("failed to add connection device for cport 0x%04hx\n", cport_id); gb_connection_hd_cport_id_free(connection); - gb_protocol_put(connection->protocol); put_device(&connection->dev); return NULL; @@ -264,6 +262,7 @@ void gb_connection_destroy(struct gb_connection *connection) gb_connection_hd_cport_id_free(connection); gb_protocol_put(connection->protocol); + connection->protocol = NULL; device_unregister(&connection->dev); } diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index eed77c3f3a7f..6aebbbd585e1 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -196,7 +196,7 @@ void gb_protocol_put(struct gb_protocol *protocol) u8 minor; u8 protocol_count; - if (!protocol) + if (WARN_ON(!protocol)) return; id = protocol->id;