All of lore.kernel.org
 help / color / mirror / Atom feed
* [withdrawn] mm-damon-sysfs-schemes-using-kmalloc_array-and-size_add.patch removed from -mm tree
@ 2025-04-23 22:21 Andrew Morton
  2025-04-23 22:40 ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2025-04-23 22:21 UTC (permalink / raw)
  To: mm-commits, sj, suhui, akpm


The quilt patch titled
     Subject: mm/damon/sysfs-schemes: use kmalloc_array() and size_add()
has been removed from the -mm tree.  Its filename was
     mm-damon-sysfs-schemes-using-kmalloc_array-and-size_add.patch

This patch was dropped because it was withdrawn

------------------------------------------------------
From: Su Hui <suhui@nfschina.com>
Subject: mm/damon/sysfs-schemes: use kmalloc_array() and size_add()
Date: Mon, 21 Apr 2025 14:24:24 +0800

It's safer to use kmalloc_array() and size_add() because it can prevent
possible overflow problem.

Link: https://lkml.kernel.org/r/20250421062423.740605-1-suhui@nfschina.com
Signed-off-by: Su Hui <suhui@nfschina.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/damon/sysfs-schemes.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/mm/damon/sysfs-schemes.c~mm-damon-sysfs-schemes-using-kmalloc_array-and-size_add
+++ a/mm/damon/sysfs-schemes.c
@@ -465,7 +465,8 @@ static ssize_t memcg_path_store(struct k
 {
 	struct damon_sysfs_scheme_filter *filter = container_of(kobj,
 			struct damon_sysfs_scheme_filter, kobj);
-	char *path = kmalloc(sizeof(*path) * (count + 1), GFP_KERNEL);
+	char *path = kmalloc_array(size_add(count, 1), sizeof(*path),
+				   GFP_KERNEL);
 
 	if (!path)
 		return -ENOMEM;
@@ -2064,7 +2065,7 @@ static int damon_sysfs_memcg_path_to_id(
 	if (!memcg_path)
 		return -EINVAL;
 
-	path = kmalloc(sizeof(*path) * PATH_MAX, GFP_KERNEL);
+	path = kmalloc_array(PATH_MAX, sizeof(*path), GFP_KERNEL);
 	if (!path)
 		return -ENOMEM;
 
_

Patches currently in -mm which might be from suhui@nfschina.com are



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-24  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 22:21 [withdrawn] mm-damon-sysfs-schemes-using-kmalloc_array-and-size_add.patch removed from -mm tree Andrew Morton
2025-04-23 22:40 ` SeongJae Park
2025-04-24  6:00   ` Dan Carpenter
2025-04-24  6:43     ` SeongJae Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.