Skip to content

Commit

Permalink
[PATCH] Fix potential OOPs in blkdev_open()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pavel Emelianov authored and Linus Torvalds committed Oct 28, 2006
1 parent f2d0aa5 commit 6a2aae0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6a2aae0

Please sign in to comment.