From fc5790bacc0b4f692632b946fb6d6efdef771681 Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 14 Feb 2022 23:20:46 +0000 Subject: [PATCH] don't deref pointer before test it is safe ok miod@ --- sys/arch/hppa/dev/mongoose.c | 5 +++-- sys/arch/macppc/dev/openpic.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/arch/hppa/dev/mongoose.c b/sys/arch/hppa/dev/mongoose.c index d4836daa796..4e3794f473e 100644 --- a/sys/arch/hppa/dev/mongoose.c +++ b/sys/arch/hppa/dev/mongoose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mongoose.c,v 1.21 2010/05/24 15:04:53 deraadt Exp $ */ +/* $OpenBSD: mongoose.c,v 1.22 2022/02/14 23:20:46 jsg Exp $ */ /* * Copyright (c) 1998-2003 Michael Shalayeff @@ -196,12 +196,13 @@ mg_intr_disestablish(void *v, void *cookie) { struct hppa_isa_iv *iv = cookie; struct mongoose_softc *sc = v; - int irq = iv - sc->sc_iv; + int irq; volatile u_int8_t *imr; if (!sc || !cookie) return; + irq = iv - sc->sc_iv; if (irq < 8) imr = &sc->sc_ctrl->imr0; else diff --git a/sys/arch/macppc/dev/openpic.c b/sys/arch/macppc/dev/openpic.c index 6d22e4478f6..4074784bcd6 100644 --- a/sys/arch/macppc/dev/openpic.c +++ b/sys/arch/macppc/dev/openpic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openpic.c,v 1.87 2021/03/11 11:16:58 jsg Exp $ */ +/* $OpenBSD: openpic.c,v 1.88 2022/02/14 23:20:46 jsg Exp $ */ /*- * Copyright (c) 2008 Dale Rahn @@ -480,13 +480,14 @@ openpic_intr_disestablish(void *lcp, void *arg) { struct intrhand *ih = arg; int irq = ih->ih_irq; - struct intrq *iq = &openpic_handler[irq]; + struct intrq *iq; int s; if (!LEGAL_IRQ(irq)) { printf("%s: bogus irq %d", __func__, irq); return; } + iq = &openpic_handler[irq]; /* * Remove the handler from the chain. -- 2.20.1