Avoid dereferencing NULL if we attempt to look up an known unit type.

This commit is contained in:
thorpej 2018-05-26 21:15:46 +00:00
parent c2b9ec1954
commit 711fe4468e
1 changed files with 3 additions and 3 deletions

View File

@ -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;
/*