From 88fa0d734c49464b2d0db0d6210f02b9fa0b950b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 16 May 2016 09:25:56 +0000 Subject: [PATCH] Don't dereference parent pointer when it is NULL. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/include/linux/device.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h index 4b4c2326ede2..d1a378fac205 100644 --- a/sys/compat/linuxkpi/common/include/linux/device.h +++ b/sys/compat/linuxkpi/common/include/linux/device.h @@ -211,11 +211,11 @@ device_register(struct device *dev) } else if (dev->parent == NULL) { bsddev = devclass_get_device(dev->class->bsdclass, 0); } - - if (bsddev == NULL) + if (bsddev == NULL && dev->parent != NULL) { bsddev = device_add_child(dev->parent->bsddev, dev->class->kobj.name, unit); - if (bsddev) { + } + if (bsddev != NULL) { if (dev->devt == 0) dev->devt = makedev(0, device_get_unit(bsddev)); device_set_softc(bsddev, dev);