quota: Fix error codes in v2_read_file_info()
authorJan Kara <jack@suse.cz>
Fri, 9 Jun 2017 07:04:47 +0000 (09:04 +0200)
committerJan Kara <jack@suse.cz>
Thu, 17 Aug 2017 17:18:11 +0000 (19:18 +0200)
v2_read_file_info() returned -1 instead of proper error codes on error.
Luckily this is not easily visible from userspace as we have called
->check_quota_file shortly before and thus already verified the quota
file is sane. Still set the error codes to proper values.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/quota_v2.c

index 373d7cfea5b021a5cda159abc715a78a55769302..21a8bdf7cfec692adf52012e1f61bcd521ab92c7 100644 (file)
@@ -99,13 +99,13 @@ static int v2_read_file_info(struct super_block *sb, int type)
 
        down_read(&dqopt->dqio_sem);
        if (!v2_read_header(sb, type, &dqhead)) {
 
        down_read(&dqopt->dqio_sem);
        if (!v2_read_header(sb, type, &dqhead)) {
-               ret = -1;
+               ret = -EIO;
                goto out;
        }
        version = le32_to_cpu(dqhead.dqh_version);
        if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
            (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1)) {
                goto out;
        }
        version = le32_to_cpu(dqhead.dqh_version);
        if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
            (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1)) {
-               ret = -1;
+               ret = -EINVAL;
                goto out;
        }
 
                goto out;
        }
 
@@ -113,7 +113,7 @@ static int v2_read_file_info(struct super_block *sb, int type)
               sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
        if (size != sizeof(struct v2_disk_dqinfo)) {
                quota_error(sb, "Can't read info structure");
               sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
        if (size != sizeof(struct v2_disk_dqinfo)) {
                quota_error(sb, "Can't read info structure");
-               ret = -1;
+               ret = -EIO;
                goto out;
        }
        info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
                goto out;
        }
        info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);