From 48d7077c007d27851952861d002d660b552b9888 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Fri, 13 Feb 2015 11:28:09 +0800 Subject: [PATCH] greybus: bundle: fix sleep-while-atomic in gb_bundle_destroy Make sure to release the spin lock protecting the interface bundle lists before tearing down the connections and removing the bundle device, which are operations that may sleep. Signed-off-by: Johan Hovold Reviewed-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/bundle.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c index d020660..93f80dc 100644 --- a/drivers/staging/greybus/bundle.c +++ b/drivers/staging/greybus/bundle.c @@ -126,6 +126,7 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 interface_id) */ void gb_bundle_destroy(struct gb_interface *intf) { + LIST_HEAD(list); struct gb_bundle *bundle; struct gb_bundle *temp; @@ -133,12 +134,14 @@ void gb_bundle_destroy(struct gb_interface *intf) return; spin_lock_irq(&gb_bundles_lock); - list_for_each_entry_safe(bundle, temp, &intf->bundles, links) { + list_splice_init(&intf->bundles, &list); + spin_unlock_irq(&gb_bundles_lock); + + list_for_each_entry_safe(bundle, temp, &list, links) { list_del(&bundle->links); gb_bundle_connections_exit(bundle); device_del(&bundle->dev); } - spin_unlock_irq(&gb_bundles_lock); } int gb_bundle_init(struct gb_interface *intf, u8 bundle_id, u8 device_id) -- 2.7.4