Module Name: src Committed By: mlelstv Date: Sun Jun 6 11:48:55 UTC 2021
Modified Files: src/sys/dev: ipmi.c Log Message: Fail open when ipmi device was found. Clear sc_envsys on failure to prevent double-free. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ipmi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ipmi.c diff -u src/sys/dev/ipmi.c:1.5 src/sys/dev/ipmi.c:1.6 --- src/sys/dev/ipmi.c:1.5 Mon Aug 17 08:34:36 2020 +++ src/sys/dev/ipmi.c Sun Jun 6 11:48:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $ */ +/* $NetBSD: ipmi.c,v 1.6 2021/06/06 11:48:55 mlelstv Exp $ */ /* * Copyright (c) 2019 Michael van Elst @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.5 2020/08/17 08:34:36 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.6 2021/06/06 11:48:55 mlelstv Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -238,7 +238,6 @@ static int bmc_io_wait(struct ipmi_softc static int bmc_io_wait_spin(struct ipmi_softc *, int, uint8_t, uint8_t); static int bmc_io_wait_sleep(struct ipmi_softc *, int, uint8_t, uint8_t); -static void *bt_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *); static void *cmn_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *); static int getbits(uint8_t *, int, int); @@ -268,6 +267,7 @@ static int kcs_reset(struct ipmi_softc * static int kcs_sendmsg(struct ipmi_softc *, int, const uint8_t *); static int kcs_recvmsg(struct ipmi_softc *, int, int *len, uint8_t *); +static void *bt_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *); static int bt_probe(struct ipmi_softc *); static int bt_reset(struct ipmi_softc *); static int bt_sendmsg(struct ipmi_softc *, int, const uint8_t *); @@ -2034,6 +2034,7 @@ ipmi_thread(void *cookie) if (sysmon_envsys_register(sc->sc_envsys)) { aprint_error_dev(self, "unable to register with sysmon\n"); sysmon_envsys_destroy(sc->sc_envsys); + sc->sc_envsys = NULL; } /* initialize sensor list for thread */ @@ -2314,6 +2315,13 @@ ipmi_suspend(device_t dev, const pmf_qua static int ipmi_open(dev_t dev, int flag, int fmt, lwp_t *l) { + struct ipmi_softc *sc; + int unit; + + unit = IPMIUNIT(dev); + if ((sc = device_lookup_private(&ipmi_cd, unit)) == NULL) + return (ENXIO); + return 0; }