]> git.hungrycats.org Git - linux/commitdiff
[PATCH] loop: trivial error number fix
authorAndrew Morton <akpm@osdl.org>
Tue, 20 Jan 2004 11:11:15 +0000 (03:11 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Tue, 20 Jan 2004 11:11:15 +0000 (03:11 -0800)
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.

drivers/block/loop.c

index f815c2f9733e8301da368b48cba45fc2147b9093..34ce36c4447b7f3d68ca0cc14bc702b55e410004 100644 (file)
@@ -683,6 +683,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
        if (!(file->f_mode & FMODE_WRITE))
                lo_flags |= LO_FLAGS_READ_ONLY;
 
+       error = -EINVAL;
        if (S_ISBLK(inode->i_mode)) {
                lo_device = I_BDEV(inode);
                if (lo_device == bdev) {
@@ -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,
                 * it's going to be read-only.
                 */
-               error = -EINVAL;
                if (!inode->i_fop->sendfile)
                        goto out_putf;
 
@@ -707,7 +707,6 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
 
                lo_blocksize = inode->i_blksize;
                lo_flags |= LO_FLAGS_DO_BMAP;
-               error = 0;
        } else
                goto out_putf;