[PATCH] Fix potential OOPs in blkdev_open()
authorPavel Emelianov <xemul@openvz.org>
Sat, 28 Oct 2006 17:38:33 +0000 (10:38 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 28 Oct 2006 18:30:52 +0000 (11:30 -0700)
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.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/block_dev.c

index bc8f27cc448314b2eaf99cc93628671d51d5adc1..702b88cbd91d2dc91eb81cb41784574b89df4edd 100644 (file)
@@ -1131,6 +1131,8 @@ static int blkdev_open(struct inode * inode, struct file * filp)
        filp->f_flags |= O_LARGEFILE;
 
        bdev = bd_acquire(inode);
+       if (bdev == NULL)
+               return -ENOMEM;
 
        res = do_open(bdev, filp, BD_MUTEX_NORMAL);
        if (res)