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 <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
u8 id;
u8 major;
u8 minor;
- u8 protocol_count;
id = protocol->id;
major = protocol->major;
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);
}