lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250926083525.13500-1-qiang.zhang@linux.dev>
Date: Fri, 26 Sep 2025 16:35:25 +0800
From: Zqiang <qiang.zhang@...ux.dev>
To: edumazet@...gle.com,
	jlayton@...nel.org,
	akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org,
	qiang.zhang@...ux.dev
Subject: [PATCH] ref_tracker: Handling kmalloc() allocation failure in __ref_tracker_dir_pr_ostream()

The kmalloc() maybe fail to allocate, causing sbuf to be null. this
commit therefore free stats memory and exit function when the sbuf
is null.

Signed-off-by: Zqiang <qiang.zhang@...ux.dev>
---
 lib/ref_tracker.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index a9e6ffcff04b..a822de2b691e 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -160,6 +160,8 @@ __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
 	}
 
 	sbuf = kmalloc(STACK_BUF_SIZE, GFP_NOWAIT | __GFP_NOWARN);
+	if (!sbuf)
+		goto end;
 
 	for (i = 0, skipped = stats->total; i < stats->count; ++i) {
 		stack = stats->stacks[i].stack_handle;
@@ -176,7 +178,7 @@ __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
 			   s->prefix, dir->class, dir, skipped, stats->total);
 
 	kfree(sbuf);
-
+end:
 	kfree(stats);
 }
 
-- 
2.17.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ