linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] cxl: Fix possible null pointer dereference in read_handle()
@ 2024-07-15  2:54 Ma Ke
  2024-07-15  5:12 ` Greg KH
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ma Ke @ 2024-07-15  2:54 UTC (permalink / raw)
  To: fbarrat, ajd, arnd, gregkh, mpe, manoj, imunsie, clombard
  Cc: stable, linuxppc-dev, linux-kernel, Ma Ke

In read_handle(), of_get_address() may return NULL if getting address and
size of the node failed. When of_read_number() uses prop to handle
conversions between different byte orders, it could lead to a null pointer
dereference. Add NULL check to fix potential issue.

Found by static analysis.

Cc: stable@vger.kernel.org
Fixes: 14baf4d9c739 ("cxl: Add guest-specific code")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
Changes in v4:
- modified vulnerability description according to suggestions, making the 
process of static analysis of vulnerabilities clearer. No active research 
on developer behavior.
Changes in v3:
- fixed up the changelog text as suggestions.
Changes in v2:
- added an explanation of how the potential vulnerability was discovered,
but not meet the description specification requirements.
---
 drivers/misc/cxl/of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/of.c b/drivers/misc/cxl/of.c
index bcc005dff1c0..d8dbb3723951 100644
--- a/drivers/misc/cxl/of.c
+++ b/drivers/misc/cxl/of.c
@@ -58,7 +58,7 @@ static int read_handle(struct device_node *np, u64 *handle)
 
 	/* Get address and size of the node */
 	prop = of_get_address(np, 0, &size, NULL);
-	if (size)
+	if (!prop || size)
 		return -EINVAL;
 
 	/* Helper to read a big number; size is in cells (not bytes) */
-- 
2.25.1


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

end of thread, other threads:[~2024-07-19  1:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-15  2:54 [PATCH v4] cxl: Fix possible null pointer dereference in read_handle() Ma Ke
2024-07-15  5:12 ` Greg KH
2024-07-15  6:28 ` Michael Ellerman
2024-07-15 17:11   ` Dan Carpenter
2024-07-16 13:27   ` Ma Ke
2024-07-19  1:23     ` Michael Ellerman
2024-07-15 13:18 ` Markus Elfring
2024-07-15 13:32   ` Greg Kroah-Hartman
2024-07-19  1:25 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).