diff mbox series

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

Message ID 20230315035746.1740236-1-windhl@126.com
State New
Headers show
Series sparc64: Add Null-checking for mdesc_grab() in ds_probe() | expand

Commit Message

Liang He March 15, 2023, 3:57 a.m. UTC
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 mbox series

Patch

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;