From 711fe4468e09a42d4276e7a2465b476e1fd18191 Mon Sep 17 00:00:00 2001 From: thorpej Date: Sat, 26 May 2018 21:15:46 +0000 Subject: [PATCH] Avoid dereferencing NULL if we attempt to look up an known unit type. --- sys/dev/sysmon/sysmon_envsys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c index c957041465ef..b46059f9744b 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 -__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 #include @@ -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; /*