diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/bsg.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/block/bsg.c b/block/bsg.c index 0b3b282f0384..5fb9b0bdbe85 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -740,8 +740,13 @@ static int bsg_put_device(struct bsg_device *bd) | |||
740 | mutex_lock(&bsg_mutex); | 740 | mutex_lock(&bsg_mutex); |
741 | 741 | ||
742 | do_free = atomic_dec_and_test(&bd->ref_count); | 742 | do_free = atomic_dec_and_test(&bd->ref_count); |
743 | if (!do_free) | 743 | if (!do_free) { |
744 | mutex_unlock(&bsg_mutex); | ||
744 | goto out; | 745 | goto out; |
746 | } | ||
747 | |||
748 | hlist_del(&bd->dev_list); | ||
749 | mutex_unlock(&bsg_mutex); | ||
745 | 750 | ||
746 | dprintk("%s: tearing down\n", bd->name); | 751 | dprintk("%s: tearing down\n", bd->name); |
747 | 752 | ||
@@ -757,10 +762,8 @@ static int bsg_put_device(struct bsg_device *bd) | |||
757 | */ | 762 | */ |
758 | ret = bsg_complete_all_commands(bd); | 763 | ret = bsg_complete_all_commands(bd); |
759 | 764 | ||
760 | hlist_del(&bd->dev_list); | ||
761 | kfree(bd); | 765 | kfree(bd); |
762 | out: | 766 | out: |
763 | mutex_unlock(&bsg_mutex); | ||
764 | kref_put(&q->bsg_dev.ref, bsg_kref_release_function); | 767 | kref_put(&q->bsg_dev.ref, bsg_kref_release_function); |
765 | if (do_free) | 768 | if (do_free) |
766 | blk_put_queue(q); | 769 | blk_put_queue(q); |