From 519bf3c3b9c09619ca90f67b194714bb5f30d491 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Tue, 13 Oct 2015 19:10:25 +0200 Subject: [PATCH] greybus: protocol: warn on protocol put errors Issue a warning if we fail to look up a protocol when dropping a reference. This should never happen as we hold a reference to the protocol module and protocols should only be deregistered at module unload. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/protocol.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index 140baa6..b9de152 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -188,7 +188,6 @@ void gb_protocol_put(struct gb_protocol *protocol) u8 id; u8 major; u8 minor; - u8 protocol_count; id = protocol->id; major = protocol->major; @@ -196,16 +195,11 @@ void gb_protocol_put(struct gb_protocol *protocol) spin_lock_irq(&gb_protocols_lock); protocol = gb_protocol_find(id, major, minor); - if (protocol) { - protocol_count = protocol->count; - if (protocol_count) - protocol->count--; - module_put(protocol->owner); - } + if (WARN_ON(!protocol || !protocol->count)) + goto out; + + protocol->count--; + module_put(protocol->owner); +out: spin_unlock_irq(&gb_protocols_lock); - if (protocol) - WARN_ON(!protocol_count); - else - pr_err("protocol id %hhu version %hhu.%hhu not found\n", - id, major, minor); } -- 2.7.4