Skip to contentSkip to conversation

block: NULL dereference on error path in __blkdev_get()

PATCH In review Dan Carpenter 2 participants 3 messages Mar 13, 2011 – Mar 18, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

"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;
Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 5 lines · Dan Carpenter

"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".

Sorry about the trouble. I hate that function. :-(

Signature · 1 line
tejun
#2 lore raw
Quoted 7 lines · Tejun Heo

Hello,

Quoted 4 lines · Dan Carpenter

"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".

Quoted 5 lines
Quoted 1 line

Sorry about the trouble. I hate that function. :-(

I thought Jens was cc'd. I'll forward the patch to him & LKML.

Thanks.

Signature · 1 line
tejun