From: Sascha Wildner Date: Tue, 16 Sep 2008 12:39:45 +0000 (+0000) Subject: MFC r1.27: X-Git-Tag: v2.0.1~11 X-Git-Url: https://repo.or.cz/w/dragonfly.git/commitdiff_plain/823b03b35daea2145991f035d0bb6b7ff83d1596 MFC r1.27: If ae is NULL, just print that the controller is unsupported and return, instead of continuing and dereferencing it later. Found-by: LLVM/Clang Static Analyzer --- diff --git a/sys/dev/raid/amr/amr.c b/sys/dev/raid/amr/amr.c index 2e03fa178c..70aa51c3d6 100644 --- a/sys/dev/raid/amr/amr.c +++ b/sys/dev/raid/amr/amr.c @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/amr/amr.c,v 1.7.2.13 2003/01/15 13:41:18 emoore Exp $ - * $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.25 2008/01/06 16:55:50 swildner Exp $ + * $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.25.4.1 2008/09/16 12:39:45 swildner Exp $ */ /* @@ -867,16 +867,26 @@ amr_bio_command(struct amr_softc *sc, struct amr_command **acp) ac->ac_bio = bio; ac->ac_data = bio->bio_buf->b_data; ac->ac_length = bio->bio_buf->b_bcount; - if (bio->bio_buf->b_cmd == BUF_CMD_READ) { + + cmd = 0; + switch(bio->bio_buf->b_cmd) { + case BUF_CMD_READ: ac->ac_flags |= AMR_CMD_DATAIN; cmd = AMR_CMD_LREAD; - } else { + break; + case BUF_CMD_WRITE: ac->ac_flags |= AMR_CMD_DATAOUT; cmd = AMR_CMD_LWRITE; + break; + case BUF_CMD_FLUSH: + ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT; + cmd = AMR_CMD_FLUSH; + break; } amrd = (struct amrd_softc *)bio->bio_driver_info; driveno = amrd->amrd_drive - sc->amr_drive; blkcount = (bio->bio_buf->b_bcount + AMR_BLKSIZE - 1) / AMR_BLKSIZE; + lba = bio->bio_offset / AMR_BLKSIZE; KKASSERT(lba < 0x100000000ULL); @@ -1738,7 +1748,8 @@ amr_describe_controller(struct amr_softc *sc) break; } } else { - prod = "unsupported controller"; + device_printf(sc->amr_dev, "\n"); + return; } /*