Skip to contentSkip to conversation

block: NULL dereference on error path in __blkdev_get()

PATCH Applied Tejun Heo 3 participants 3 messages Mar 18, 2011 – Mar 19, 2011 VFS

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 block: NULL dereference on error path in __blkdev_get()

From: Dan Carpenter <[email protected]>

"disk" is always NULL when we goto out. There was a check for this before, but it was removed in 69e02c59a7d9 "block: Don't check events while open is in progress".

fs/block_dev.c +1 -1
index fbe05cb..7d02afb 100644
@@ -1181,9 +1181,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
  out_unlock_bdev:
 	mutex_unlock(&bdev->bd_mutex);
 	disk_unblock_events(disk);
- out:
 	module_put(disk->fops->owner);
 	put_disk(disk);
+ out:
 	bdput(bdev);
 
 	return ret;
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Tejun Heo

From: Dan Carpenter <[email protected]>

"disk" is always NULL when we goto out.  There was a check for this before, but it was removed in 69e02c59a7d9 "block: Don't check events while open is in progress".

I was running into this problem too; this patch fixes the problem.

Quoted 22 lines
fs/block_dev.c +0 -0
index fbe05cb..7d02afb 100644
@@ -1181,9 +1181,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)

 out_unlock_bdev:
       mutex_unlock(&bdev->bd_mutex);
       disk_unblock_events(disk);
- out:
       module_put(disk->fops->owner);
       put_disk(disk);
+ out:
       bdput(bdev);

       return ret;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Applied
#2 lore raw
In reply to Tejun Heo
Quoted 5 lines · Tejun Heo

From: Dan Carpenter <[email protected]>

"disk" is always NULL when we goto out. There was a check for this before, but it was removed in 69e02c59a7d9 "block: Don't check events while open is in progress".

Thanks, applied.

Signature · 1 line
Jens Axboe