Skip to contentSkip to conversation

sparc64: Add Null-checking for mdesc_grab() in ds_probe()

PATCH New Liang He 1 participant 1 message Mar 15, 2023 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 sparc64: Add Null-checking for mdesc_grab() in ds_probe()

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/")
---
 arch/sparc/kernel/ds.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/sparc/kernel/ds.c +4 -0
index 4a5bdb0df779..e14a8fb466b8 100644
@@ -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;
Signature · 1 line
2.25.1