From: Greg Kroah-Hartman Date: Wed, 24 Dec 2014 21:12:10 +0000 (-0800) Subject: greybus: protocol: fix oops when no protocol is assigned X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=23ad7bb96bb59e1f91a95a494cca303a8f7d300a;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git greybus: protocol: fix oops when no protocol is assigned When removing a connection with no protocol assigned to it, the kernel oopses as we always thought protocols were always there. Fix that problem, oopses are bad. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Alex Elder --- diff --git a/drivers/staging/greybus/protocol.c b/drivers/staging/greybus/protocol.c index 4d6ffdd04ab8..562401d77d6d 100644 --- a/drivers/staging/greybus/protocol.c +++ b/drivers/staging/greybus/protocol.c @@ -165,10 +165,16 @@ struct gb_protocol *gb_protocol_get(u8 id, u8 major, u8 minor) void gb_protocol_put(struct gb_protocol *protocol) { - u8 major = protocol->major; - u8 minor = protocol->minor; + u8 major; + u8 minor; u8 protocol_count; + if (!protocol) + return; + + major = protocol->major; + minor = protocol->minor; + spin_lock_irq(&gb_protocols_lock); protocol = _gb_protocol_find(protocol->id, protocol->major, protocol->minor);