sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparc/mm: add check for mdesc_grab()
@ 2023-03-15  5:39 Liang He
  0 siblings, 0 replies; only message in thread
From: Liang He @ 2023-03-15  5:39 UTC (permalink / raw)
  To: davem, windhl, sparclinux

In of_node_to_nid() and numa_parse_mdesc(), we should consider
the return value of mdesc_grab() as it may return NULL.
We should add check to avoid NPD bug.

Fixes: 27137e5285a3 ("sparc,sparc64: unify mm/")
Signed-off-by: Liang He <windhl@126.com>
---
 arch/sparc/mm/init_64.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 04f9db0c3111..d0a0c1a78b41 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -1176,6 +1176,8 @@ int of_node_to_nid(struct device_node *dp)
 	cfg_handle = (regs->phys_addr >> 32UL) & 0x0fffffff;
 
 	md = mdesc_grab();
+	if (!md)
+		return -1;
 
 	count = 0;
 	nid = NUMA_NO_NODE;
@@ -1449,6 +1451,9 @@ static int __init numa_parse_mdesc(void)
 	int i, j, err, count;
 	u64 node;
 
+	if (!md)
+		return -ENODEV;
+
 	node = mdesc_node_by_name(md, MDESC_NODE_NULL, "latency-groups");
 	if (node == MDESC_NODE_NULL) {
 		mdesc_release(md);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-15  5:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  5:39 [PATCH] sparc/mm: add check for mdesc_grab() Liang He

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).