Commit f76fe2f6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] loop: trivial error number fix

From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

This patch fixes the error number when invalid file is passed (neother
S_ISBLK nor S_ISREG is true).  We should return -EINVAL.
parent 56f4a654
...@@ -683,6 +683,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -683,6 +683,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
if (!(file->f_mode & FMODE_WRITE)) if (!(file->f_mode & FMODE_WRITE))
lo_flags |= LO_FLAGS_READ_ONLY; lo_flags |= LO_FLAGS_READ_ONLY;
error = -EINVAL;
if (S_ISBLK(inode->i_mode)) { if (S_ISBLK(inode->i_mode)) {
lo_device = I_BDEV(inode); lo_device = I_BDEV(inode);
if (lo_device == bdev) { if (lo_device == bdev) {
...@@ -698,7 +699,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -698,7 +699,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
* If we can't read - sorry. If we only can't write - well, * If we can't read - sorry. If we only can't write - well,
* it's going to be read-only. * it's going to be read-only.
*/ */
error = -EINVAL;
if (!inode->i_fop->sendfile) if (!inode->i_fop->sendfile)
goto out_putf; goto out_putf;
...@@ -707,7 +707,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file, ...@@ -707,7 +707,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
lo_blocksize = inode->i_blksize; lo_blocksize = inode->i_blksize;
lo_flags |= LO_FLAGS_DO_BMAP; lo_flags |= LO_FLAGS_DO_BMAP;
error = 0;
} else } else
goto out_putf; goto out_putf;
......
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