* [PATCH] mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs()
@ 2022-03-02 11:11 Jiapeng Chong
2022-03-02 11:26 ` SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2022-03-02 11:11 UTC (permalink / raw)
To: sj; +Cc: akpm, linux-mm, linux-kernel, Jiapeng Chong, Abaci Robot
The error code is missing in this code scenario, add the error code
'-ENOMEM' to the return value 'err'.
Eliminate the follow smatch warning:
mm/damon/sysfs.c:1647 damon_sysfs_attrs_add_dirs() warn: missing error
code 'err'.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
mm/damon/sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 32a9d21c0db5..0eca71163924 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1643,8 +1643,10 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs)
attrs->intervals = intervals;
nr_regions_range = damon_sysfs_ul_range_alloc(10, 1000);
- if (!nr_regions_range)
+ if (!nr_regions_range) {
+ err = -ENOMEM;
goto put_intervals_out;
+ }
err = kobject_init_and_add(&nr_regions_range->kobj,
&damon_sysfs_ul_range_ktype, &attrs->kobj,
--
2.20.1.7.g153144c
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs()
2022-03-02 11:11 [PATCH] mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs() Jiapeng Chong
@ 2022-03-02 11:26 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2022-03-02 11:26 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: sj, akpm, linux-mm, linux-kernel, Abaci Robot
On Wed, 2 Mar 2022 19:11:20 +0800 Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
> The error code is missing in this code scenario, add the error code
> '-ENOMEM' to the return value 'err'.
>
> Eliminate the follow smatch warning:
>
> mm/damon/sysfs.c:1647 damon_sysfs_attrs_add_dirs() warn: missing error
> code 'err'.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Good eye, thank you!
Reviewed-by: SeongJae Park <sj@kernel.org>
Andrew, please fold this patch into
mm-damon-implement-a-minimal-stub-for-sysfs-based-damon-interface.patch[1].
[1] https://www.ozlabs.org/~akpm/mmotm/broken-out/mm-damon-implement-a-minimal-stub-for-sysfs-based-damon-interface.patch
Thanks,
SJ
> ---
> mm/damon/sysfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 32a9d21c0db5..0eca71163924 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -1643,8 +1643,10 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs)
> attrs->intervals = intervals;
>
> nr_regions_range = damon_sysfs_ul_range_alloc(10, 1000);
> - if (!nr_regions_range)
> + if (!nr_regions_range) {
> + err = -ENOMEM;
> goto put_intervals_out;
> + }
>
> err = kobject_init_and_add(&nr_regions_range->kobj,
> &damon_sysfs_ul_range_ktype, &attrs->kobj,
> --
> 2.20.1.7.g153144c
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-02 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 11:11 [PATCH] mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs() Jiapeng Chong
2022-03-02 11:26 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox