UPSTREAM: mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
DAMOS tried regions sysfs directory allocation function (damon_sysfs_scheme_regions_alloc()) is not handling the memory allocation failure. In the case, the code will dereference NULL pointer. Handle the failure to avoid such invalid access. Link: https://lkml.kernel.org/r/20231106233408.51159-3-sj@kernel.org Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory") Signed-off-by: SeongJae Park <sj@kernel.org> Cc: <stable@vger.kernel.org> [6.2+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 84055688b6bc075c92a88e2d6c3ad26ab93919f9) Bug: 300502883 Change-Id: I86ecb2f3cf1604199b5567576b1fa583914f7f36 Signed-off-by: cui yangpei <cuiyangpei@xiaomi.com>
This commit is contained in:
parent
7fbeab3c65
commit
1cedfc05e9
1 changed files with 3 additions and 0 deletions
|
|
@ -162,6 +162,9 @@ damon_sysfs_scheme_regions_alloc(void)
|
|||
struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!regions)
|
||||
return NULL;
|
||||
|
||||
regions->kobj = (struct kobject){};
|
||||
INIT_LIST_HEAD(®ions->regions_list);
|
||||
regions->nr_regions = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue