From cd8aaf212102bdad98092dfbe89be33c3bfca9e0 Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Sun, 22 Feb 2004 09:58:34 +0000 Subject: [PATCH] Check that twed_sc is non-NULL before dereferencing it, not after. Reported by: "Ted Unangst" Approved by: rwatson (mentor) --- sys/dev/twe/twe_freebsd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c index 32175c13a37..1f13391bb07 100644 --- a/sys/dev/twe/twe_freebsd.c +++ b/sys/dev/twe/twe_freebsd.c @@ -744,9 +744,9 @@ twed_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t l dp = arg; twed_sc = (struct twed_softc *)dp->d_drv1; - twe_sc = (struct twe_softc *)twed_sc->twed_controller; - if (!twed_sc || !twe_sc) + if (twed_sc == NULL) return(ENXIO); + twe_sc = (struct twe_softc *)twed_sc->twed_controller; if (length > 0) { if ((error = twe_dump_blocks(twe_sc, twed_sc->twed_drive->td_twe_unit, offset / TWE_BLOCK_SIZE, virtual, length / TWE_BLOCK_SIZE)) != 0)