From: Andrew Morton Fix up blkdev_open() error-path refcounting. Cc: Rafał Bilski Cc: Al Viro Cc: Christoph Hellwig Signed-off-by: Andrew Morton --- fs/block_dev.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) diff -puN fs/block_dev.c~remove-bdput-from-do_open-in-fs-block_devc-fix fs/block_dev.c --- a/fs/block_dev.c~remove-bdput-from-do_open-in-fs-block_devc-fix +++ a/fs/block_dev.c @@ -1246,8 +1246,10 @@ static int blkdev_open(struct inode * in return -ENOMEM; res = do_open(bdev, filp, 0); - if (res) + if (res) { + bdput(bdev); return res; + } if (!(filp->f_flags & O_EXCL) ) return 0; _