Skip to content

Commit 8405568

Browse files
sjp38akpm00
authored andcommitted
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: 9277d03 ("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>
1 parent b4936b5 commit 8405568

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

mm/damon/sysfs-schemes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ damon_sysfs_scheme_regions_alloc(void)
162162
struct damon_sysfs_scheme_regions *regions = kmalloc(sizeof(*regions),
163163
GFP_KERNEL);
164164

165+
if (!regions)
166+
return NULL;
167+
165168
regions->kobj = (struct kobject){};
166169
INIT_LIST_HEAD(&regions->regions_list);
167170
regions->nr_regions = 0;

0 commit comments

Comments
 (0)