diff mbox

[15/27] quota: Fix error codes in v2_read_file_info()

Message ID 20170816154127.7048-16-jack@suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kara Aug. 16, 2017, 3:41 p.m. UTC
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.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/quota/quota_v2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Andreas Dilger Aug. 16, 2017, 6 p.m. UTC | #1
> On Aug 16, 2017, at 9:41 AM, Jan Kara <jack@suse.cz> wrote:
> 
> 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.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>

Doh, should read patches ahead before replying.  Still, could return the
error codes from ->quota_read() via v2_read_header() as previously suggested.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/quota/quota_v2.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
> index 373d7cfea5b0..21a8bdf7cfec 100644
> --- a/fs/quota/quota_v2.c
> +++ b/fs/quota/quota_v2.c
> @@ -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)) {
> -		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)) {
> -		ret = -1;
> +		ret = -EINVAL;
> 		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");
> -		ret = -1;
> +		ret = -EIO;
> 		goto out;
> 	}
> 	info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);
> --
> 2.12.3
> 


Cheers, Andreas
diff mbox

Patch

diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c
index 373d7cfea5b0..21a8bdf7cfec 100644
--- a/fs/quota/quota_v2.c
+++ b/fs/quota/quota_v2.c
@@ -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)) {
-		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)) {
-		ret = -1;
+		ret = -EINVAL;
 		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");
-		ret = -1;
+		ret = -EIO;
 		goto out;
 	}
 	info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);