Skip to contentSkip to conversation

Fix potential OOPs in blkdev_open()

PATCH New Pavel Emelianov 1 participant 1 message Oct 20, 2006 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix potential OOPs in blkdev_open()

blkdev_open() calls bc_acquire() to get a struct block_device. Since bc_acquire() may return NULL when system is out of memory an appropriate check is required.

fs/block_dev.c renamed from fs/block_dev.c.bdopen +2 -0
@@ -1126,6 +1126,8 @@ static int blkdev_open(struct inode * in
 	filp->f_flags |= O_LARGEFILE;
 
 	bdev = bd_acquire(inode);
+	if (bdev == NULL)
+		return -ENOMEM;
 
 	res = do_open(bdev, filp, BD_MUTEX_NORMAL);
 	if (res)