diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-18 12:15:36 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-18 12:15:36 +0000 |
commit | 96e01a0efb268766622560f66597f30ce09e9801 (patch) | |
tree | 04b407301da31cff67fdf52a2a95f7ff011c00ea /sys | |
parent | 244b6c22a9e7f7a6799e452daedb89b5d9ce2e53 (diff) |
Test for device_lookup() returning NULL in gpioioctl() and gpioclose().
Coverity CIDs 1453046, 1453184.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/gpio/gpio.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/dev/gpio/gpio.c b/sys/dev/gpio/gpio.c index 05fbd6ed419..0aa7ed5c69b 100644 --- a/sys/dev/gpio/gpio.c +++ b/sys/dev/gpio/gpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpio.c,v 1.14 2015/08/27 05:48:40 deraadt Exp $ */ +/* $OpenBSD: gpio.c,v 1.15 2017/08/18 12:15:35 jsg Exp $ */ /* * Copyright (c) 2008 Marc Balmer <mbalmer@openbsd.org> @@ -267,6 +267,9 @@ gpioclose(dev_t dev, int flag, int mode, struct proc *p) struct gpio_softc *sc; sc = (struct gpio_softc *)device_lookup(&gpio_cd, minor(dev)); + if (sc == NULL) + return (ENXIO); + sc->sc_opened = 0; return (0); @@ -299,6 +302,9 @@ gpioioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) int pin, value, flags, npins, found; sc = (struct gpio_softc *)device_lookup(&gpio_cd, minor(dev)); + if (sc == NULL) + return (ENXIO); + gc = sc->sc_gc; switch (cmd) { |