greybus: loopback: make sure to list_del on connection_exit
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Fri, 4 Sep 2015 15:53:31 +0000 (16:53 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Fri, 4 Sep 2015 21:50:39 +0000 (14:50 -0700)
commitff477d073f2e71a1fa59f86cb44bd9d48674a71b
tree1d67eeeace9652b867b20bbf633c6c59efec52b1
parent566830fdb1b666b5159709a9e66ed5f2c85f58b7
greybus: loopback: make sure to list_del on connection_exit

gb_loopback_connection_exit does a kfree on a data structure associated
with a loopback connection but fails to do a corresponding list_del(). On
subsequent enumerations this can lead to a NULL pointer dereference. Each
list_add in gb_loopback_connection_init() must have a corresponding
list_del in gb_loopback_connection_exit(), this patch adds the relevant
list_del() and ensures that an appropriate mutex protecting gb_dev.list is
held while doing so.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c