summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2018-05-26 21:15:46 +0000
committerthorpej <thorpej@NetBSD.org>2018-05-26 21:15:46 +0000
commit885d583fcbcb833aac545cb6e186c6d28b7c3dbd (patch)
tree1616c8ce8ed33a2cdef01acaafb91ec31bca2545 /sys/dev/sysmon
parentdb12b27c3f70eed4d04b8b073a164e727a98ec18 (diff)
Avoid dereferencing NULL if we attempt to look up an known unit type.
Diffstat (limited to 'sys/dev/sysmon')
-rw-r--r--sys/dev/sysmon/sysmon_envsys.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c
index c957041465e..b46059f9744 100644
--- a/sys/dev/sysmon/sysmon_envsys.c
+++ b/sys/dev/sysmon/sysmon_envsys.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.143 2018/05/26 21:15:46 thorpej Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -578,7 +578,7 @@ sysmon_envsys_sensor_attach(struct sysmon_envsys *sme, envsys_data_t *edata)
* Find the correct units for this sensor.
*/
sdt_units = sme_find_table_entry(SME_DESC_UNITS, edata->units);
- if (sdt_units->type == -1)
+ if (sdt_units == NULL || sdt_units->type == -1)
return EINVAL;
/*