[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211208020204.GA13528@hsiangkao-HP-ZHAN-66-Pro-G1>
Date: Wed, 8 Dec 2021 10:02:05 +0800
From: Gao Xiang <xiang@...nel.org>
To: Huang Jianan <jnhuang95@...il.com>
Cc: linux-erofs@...ts.ozlabs.org, xiang@...nel.org, chao@...nel.org,
linux-kernel@...r.kernel.org, guoweichao@...o.com,
guanyuwei@...o.com, yh@...o.com, zhangshiming@...o.com,
Huang Jianan <huangjianan@...o.com>
Subject: Re: [PATCH v7 2/3] erofs: add sysfs interface
Hi Jianan,
On Wed, Dec 01, 2021 at 10:54:36PM +0800, Huang Jianan wrote:
> Add sysfs interface to configure erofs related parameters later.
>
> Signed-off-by: Huang Jianan <huangjianan@...o.com>
> Reviewed-by: Chao Yu <chao@...nel.org>
...
> +static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct erofs_sb_info *sbi = container_of(kobj, struct erofs_sb_info,
> + s_kobj);
> + struct erofs_attr *a = container_of(attr, struct erofs_attr, attr);
> + unsigned char *ptr = __struct_ptr(sbi, a->struct_type, a->offset);
> + unsigned long t;
> + int ret;
> +
> + switch (a->attr_id) {
> + case attr_pointer_ui:
> + if (!ptr)
> + return 0;
> + ret = kstrtoul(skip_spaces(buf), 0, &t);
> + if (ret)
> + return ret;
> + if (t > UINT_MAX)
> + return -EINVAL;
Intel 0day CI report a warning.
https://lore.kernel.org/r/61aede22.lQ5T3RqGz2H%2Fg4aR%25lkp@intel.com
I fix this like below:
diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c
index 41a7de772412..33e15fa63c82 100644
--- a/fs/erofs/sysfs.c
+++ b/fs/erofs/sysfs.c
@@ -128,8 +128,8 @@ static ssize_t erofs_attr_store(struct kobject *kobj, struct attribute *attr,
ret = kstrtoul(skip_spaces(buf), 0, &t);
if (ret)
return ret;
- if (t > UINT_MAX)
- return -EINVAL;
+ if (t != (unsigned int)t)
+ return -ERANGE;
*(unsigned int *)ptr = t;
return len;
case attr_pointer_bool:
Thanks,
Gao Xiang
Powered by blists - more mailing lists