mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs()
Subsystems (2)
PATCH 1/1 mm/damon/sysfs: Fix missing error code in damon_sysfs_attrs_add_dirs()
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 <[email protected]>
Signed-off-by Jiapeng Chong <[email protected]>
--- mm/damon/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/damon/sysfs.c +3 -1
@@ -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,
Signature · 1 line
2.20.1.7.g153144c
Quoted 10 lines · On Wed, 2 Mar 2022 19:11:20 +0800 Jiapeng Chong…
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:1647damon_sysfs_attrs_add_dirs()warn: missing error code 'err'.Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>
Good eye, thank you!
Reviewed-by SeongJae Park <[email protected]>
Andrew, please fold this patch into mm-damon-implement-a-minimal-stub-for-sysfs-based-damon-interface.patch[1].
Thanks,
SJ
Quoted 22 lines
--- mm/damon/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/damon/sysfs.c +3
-1@@ -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,Signature · 1 line
2.20.1.7.g153144c