From f76fe2f64a622d02e7755c423db0c3cd4ba62589 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 20 Jan 2004 03:11:15 -0800 Subject: [PATCH] [PATCH] loop: trivial error number fix From: OGAWA Hirofumi 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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index f815c2f9733e8..34ce36c4447b7 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -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; -- 2.53.0