sparclinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparc64: Add Null-checking for mdesc_grab() in ds_probe()
@ 2023-03-15  3:57 Liang He
  0 siblings, 0 replies; only message in thread
From: Liang He @ 2023-03-15  3:57 UTC (permalink / raw)
  To: davem, windhl, sparclinux

In ds_probe(), the mdesc_grab() may return NULL pointer,
we should add the check to avoid NPD bug.

Fixes: a88b5ba8bd8a ("sparc,sparc64: unify kernel/")
Signed-off-by: Liang He <windhl@126.com>
---
 arch/sparc/kernel/ds.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
index 4a5bdb0df779..e14a8fb466b8 100644
--- a/arch/sparc/kernel/ds.c
+++ b/arch/sparc/kernel/ds.c
@@ -1178,6 +1178,10 @@ static int ds_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 		goto out_err;
 
 	hp = mdesc_grab();
+	if (!hp) {
+		err = -ENODEV;
+		goto out_err;
+	}
 	val = mdesc_get_property(hp, vdev->mp, "id", NULL);
 	if (val)
 		dp->id = *val;
-- 
2.25.1


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  3:57 [PATCH] sparc64: Add Null-checking for mdesc_grab() in ds_probe() 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).