summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-05-16 09:25:56 +0000
committerhselasky <hselasky@FreeBSD.org>2016-05-16 09:25:56 +0000
commitc8b75fc824d9701ee119de24599a43d3212dd4ad (patch)
tree5f260376093984e2ff0337e02266d51ffb571d08
parentba172014a8320954d6eb2282a9c2a1cfeac17bef (diff)
downloadFreeBSD-src-c8b75fc824d9701ee119de24599a43d3212dd4ad.zip
FreeBSD-src-c8b75fc824d9701ee119de24599a43d3212dd4ad.tar.gz
Don't dereference parent pointer when it is NULL.
MFC after: 1 week Sponsored by: Mellanox Technologies
-rw-r--r--sys/compat/linuxkpi/common/include/linux/device.h6
1 files 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 4b4c232..d1a378f 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);
OpenPOWER on IntegriCloud