Fri Aug 30 00:33:55 2019 UTC ()
Don't dereference pointer when we're about to panic because it's null.

Reported by Dr Silvio Cesare of InfoSect.


(riastradh)
diff -r1.6 -r1.7 src/sys/arch/arm/gemini/gemini_ipi.c

cvs diff -r1.6 -r1.7 src/sys/arch/arm/gemini/gemini_ipi.c (expand / switch to unified diff)

--- src/sys/arch/arm/gemini/gemini_ipi.c 2012/10/27 17:17:38 1.6
+++ src/sys/arch/arm/gemini/gemini_ipi.c 2019/08/30 00:33:55 1.7
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1#include "opt_gemini.h" 1#include "opt_gemini.h"
2#if !defined(GEMINI_MASTER) && !defined(GEMINI_SLAVE) 2#if !defined(GEMINI_MASTER) && !defined(GEMINI_SLAVE)
3# error IPI needs GEMINI_MASTER or GEMINI_SLAVE 3# error IPI needs GEMINI_MASTER or GEMINI_SLAVE
4#endif 4#endif
5#include "locators.h" 5#include "locators.h"
6#include "geminiipm.h" 6#include "geminiipm.h"
7 7
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9 9
10__KERNEL_RCSID(0, "$NetBSD: gemini_ipi.c,v 1.6 2012/10/27 17:17:38 chs Exp $"); 10__KERNEL_RCSID(0, "$NetBSD: gemini_ipi.c,v 1.7 2019/08/30 00:33:55 riastradh Exp $");
11 11
12#include <sys/param.h> 12#include <sys/param.h>
13#include <sys/systm.h> 13#include <sys/systm.h>
14#include <sys/device.h> 14#include <sys/device.h>
15#include <sys/intr.h> 15#include <sys/intr.h>
16#include <sys/malloc.h> 16#include <sys/malloc.h>
17#include <arch/arm/gemini/gemini_obiovar.h> 17#include <arch/arm/gemini/gemini_obiovar.h>
18#include <arch/arm/gemini/gemini_ipivar.h> 18#include <arch/arm/gemini/gemini_ipivar.h>
19#include <arch/arm/gemini/gemini_reg.h> 19#include <arch/arm/gemini/gemini_reg.h>
20 20
21static int gemini_ipi_match(device_t, cfdata_t, void *); 21static int gemini_ipi_match(device_t, cfdata_t, void *);
22static void gemini_ipi_attach(device_t, device_t, void *); 22static void gemini_ipi_attach(device_t, device_t, void *);
23static int gemini_ipiintr(void *); 23static int gemini_ipiintr(void *);
@@ -159,27 +159,27 @@ ipi_intr_establish(int (*func)(void *),  @@ -159,27 +159,27 @@ ipi_intr_establish(int (*func)(void *),
159 panic("%s: gemini_ipi_intrq_insert failed", 159 panic("%s: gemini_ipi_intrq_insert failed",
160 device_xname(sc->sc_dev)); 160 device_xname(sc->sc_dev));
161#endif 161#endif
162 162
163 return ih; 163 return ih;
164} 164}
165 165
166void 166void
167ipi_intr_disestablish(void *ih) 167ipi_intr_disestablish(void *ih)
168{ 168{
169 gemini_ipi_softc_t *sc = gemini_ipi_sc; 169 gemini_ipi_softc_t *sc = gemini_ipi_sc;
170 170
171 if (sc == NULL) 171 if (sc == NULL)
172 panic("%s: NULL gemini_ipi_sc", device_xname(sc->sc_dev)); 172 panic("NULL gemini_ipi_sc");
173 173
174 gemini_ipi_intrq_remove(sc, ih); 174 gemini_ipi_intrq_remove(sc, ih);
175} 175}
176 176
177int 177int
178ipi_send(void) 178ipi_send(void)
179{ 179{
180 gemini_ipi_softc_t *sc = gemini_ipi_sc; 180 gemini_ipi_softc_t *sc = gemini_ipi_sc;
181 uint32_t r; 181 uint32_t r;
182 uint32_t bit; 182 uint32_t bit;
183 bus_addr_t off; 183 bus_addr_t off;
184 184
185 if (sc == NULL) 185 if (sc == NULL)