summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2018-05-05 00:14:28 +0000
committerpgoyette <pgoyette@NetBSD.org>2018-05-05 00:14:28 +0000
commit2decb16771ba8aff79a8f98256ee18f4bc0979fa (patch)
tree436b74ccc3ea03f112b5042f9420a3e4f7a22340 /sys
parent067d700389815974047d7adef3f7fa62596cce15 (diff)
Defend against some table-lookup-not-found errors.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/sysmon/sysmon_envsys.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c
index c4081284af0..c957041465e 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.141 2017/09/11 06:02:09 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette 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.141 2017/09/11 06:02:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.142 2018/05/05 00:14:28 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1706,6 +1706,8 @@ sme_update_sensor_dictionary(prop_object_t dict, envsys_data_t *edata,
* update sensor's type.
*/
sdt = sme_find_table_entry(SME_DESC_UNITS, edata->units);
+ if (sdt == NULL)
+ return EINVAL;
DPRINTFOBJ(("%s: sensor #%d units=%d (%s)\n", __func__, edata->sensor,
sdt->type, sdt->desc));
@@ -1784,6 +1786,8 @@ sme_update_sensor_dictionary(prop_object_t dict, envsys_data_t *edata,
if (edata->units == ENVSYS_DRIVE) {
sdt = sme_find_table_entry(SME_DESC_DRIVE_STATES,
edata->value_cur);
+ if (sdt == NULL)
+ return EINVAL;
error = sme_sensor_upstring(dict, "drive-state", sdt->desc);
if (error)
return error;
@@ -1796,6 +1800,8 @@ sme_update_sensor_dictionary(prop_object_t dict, envsys_data_t *edata,
if (edata->units == ENVSYS_BATTERY_CAPACITY) {
sdt = sme_find_table_entry(SME_DESC_BATTERY_CAPACITY,
edata->value_cur);
+ if (sdt == NULL)
+ return EINVAL;
error = sme_sensor_upstring(dict, "battery-capacity",
sdt->desc);
if (error)