Commit 02a54dd1 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: core: add defensive connection disable post disconnect

Bundle drivers *must* disable their connections in the disconnect
callback, but add a defensive test and warn about buggy drivers
nonetheless.

Note that bundle drivers would generally release their state containers
in disconnect so a failure stop I/O could potentially lead to
use-after-free bugs in any late operation completion callbacks.
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent fa8369c1
...@@ -165,6 +165,13 @@ static int greybus_remove(struct device *dev) ...@@ -165,6 +165,13 @@ static int greybus_remove(struct device *dev)
gb_connection_disable_rx(connection); gb_connection_disable_rx(connection);
driver->disconnect(bundle); driver->disconnect(bundle);
/* Catch buggy drivers that fail to disable their connections. */
list_for_each_entry(connection, &bundle->connections, bundle_links) {
if (WARN_ON(connection->state != GB_CONNECTION_STATE_DISABLED))
gb_connection_disable(connection);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment