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: <20250521143033.53620-1-yechey@ai-sast.com>
Date: Wed, 21 May 2025 22:30:33 +0800
From: Ye Chey <yechey@...sast.com>
To: kent.overstreet@...ux.dev
Cc: linux-bcachefs@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Ye Chey <yechey@...sast.com>
Subject: [PATCH] bcachefs: fix potential NULL pointer dereference in bch2_bkey_buf_realloc

Add error checking for mempool_alloc return value to avoid potential NULL
pointer dereference when memory allocation fails.

Signed-off-by: Ye Chey <yechey@...sast.com>
---
 fs/bcachefs/bkey_buf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/bcachefs/bkey_buf.h b/fs/bcachefs/bkey_buf.h
index a30c4ae8e..8272a1830 100644
--- a/fs/bcachefs/bkey_buf.h
+++ b/fs/bcachefs/bkey_buf.h
@@ -16,6 +16,8 @@ static inline void bch2_bkey_buf_realloc(struct bkey_buf *s,
 	if (s->k == (void *) s->onstack &&
 	    u64s > ARRAY_SIZE(s->onstack)) {
 		s->k = mempool_alloc(&c->large_bkey_pool, GFP_NOFS);
+		if (!s->k)
+			return;
 		memcpy(s->k, s->onstack, sizeof(s->onstack));
 	}
 }
-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ