mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
mm/damon/sysfs-schemes: handle tried regions sysfs directory allocation failure
commit84055688b6
upstream. 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:9277d0367b
("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fadc9f448f
commit
2e4dec8e1b
@ -125,6 +125,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…
Reference in New Issue
Block a user