Commit 6a2aae06 authored by Pavel Emelianov's avatar Pavel Emelianov Committed by Linus Torvalds

[PATCH] 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.
Signed-off-by: default avatarPavel Emelianov <xemul@openvz.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f2d0aa5b
...@@ -1131,6 +1131,8 @@ static int blkdev_open(struct inode * inode, struct file * filp) ...@@ -1131,6 +1131,8 @@ static int blkdev_open(struct inode * inode, struct file * filp)
filp->f_flags |= O_LARGEFILE; filp->f_flags |= O_LARGEFILE;
bdev = bd_acquire(inode); bdev = bd_acquire(inode);
if (bdev == NULL)
return -ENOMEM;
res = do_open(bdev, filp, BD_MUTEX_NORMAL); res = do_open(bdev, filp, BD_MUTEX_NORMAL);
if (res) if (res)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment