Check that amrd_sc is non-NULL before dereferencing it, not after.

Reported by:	"Ted Unangst" <tedu@coverity.com>
Approved by:	rwatson (mentor)
This commit is contained in:
Colin Percival 2004-02-22 10:00:05 +00:00
parent cd8aaf2121
commit 9a6caa1afc

View File

@ -157,9 +157,9 @@ amrd_dump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t l
dp = arg;
amrd_sc = (struct amrd_softc *)dp->d_drv1;
amr_sc = (struct amr_softc *)amrd_sc->amrd_controller;
if (!amrd_sc || !amr_sc)
if (amrd_sc == NULL)
return(ENXIO);
amr_sc = (struct amr_softc *)amrd_sc->amrd_controller;
if (length > 0) {
int driveno = amrd_sc->amrd_drive - amr_sc->amr_drive;