diff options
-rw-r--r-- | fs/block_dev.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 75c47a21b2f0..3635315e3b99 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -963,20 +963,20 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder, | |||
963 | 963 | ||
964 | err = bd_claim(bdev, holder); | 964 | err = bd_claim(bdev, holder); |
965 | if (err) | 965 | if (err) |
966 | goto out; | 966 | goto fail; |
967 | 967 | ||
968 | found = find_bd_holder(bdev, bo); | 968 | found = find_bd_holder(bdev, bo); |
969 | if (found) | 969 | if (found) |
970 | goto out; | 970 | goto fail; |
971 | 971 | ||
972 | err = add_bd_holder(bdev, bo); | 972 | err = add_bd_holder(bdev, bo); |
973 | if (err) | 973 | if (err) |
974 | bd_release(bdev); | 974 | bd_release(bdev); |
975 | 975 | else | |
976 | out: | 976 | bo = NULL; |
977 | if (err || found) | 977 | fail: |
978 | free_bd_holder(bo); | ||
979 | mutex_unlock(&bdev->bd_mutex); | 978 | mutex_unlock(&bdev->bd_mutex); |
979 | free_bd_holder(bo); | ||
980 | return err; | 980 | return err; |
981 | } | 981 | } |
982 | 982 | ||
@@ -991,15 +991,12 @@ out: | |||
991 | static void bd_release_from_kobject(struct block_device *bdev, | 991 | static void bd_release_from_kobject(struct block_device *bdev, |
992 | struct kobject *kobj) | 992 | struct kobject *kobj) |
993 | { | 993 | { |
994 | struct bd_holder *bo; | ||
995 | |||
996 | if (!kobj) | 994 | if (!kobj) |
997 | return; | 995 | return; |
998 | 996 | ||
999 | mutex_lock(&bdev->bd_mutex); | 997 | mutex_lock(&bdev->bd_mutex); |
1000 | bd_release(bdev); | 998 | bd_release(bdev); |
1001 | if ((bo = del_bd_holder(bdev, kobj))) | 999 | free_bd_holder(del_bd_holder(bdev, kobj)); |
1002 | free_bd_holder(bo); | ||
1003 | mutex_unlock(&bdev->bd_mutex); | 1000 | mutex_unlock(&bdev->bd_mutex); |
1004 | } | 1001 | } |
1005 | 1002 | ||