From ee40c7aa76b2e91bd0699e6229aaf7593efcf2c8 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 4 May 2006 13:01:16 +0000 Subject: [PATCH] Use G_RAID3_FOREACH_SAFE_BIO() macro instead of G_RAID3_FOREACH_BIO() in two places where g_io_request() is called. g_io_request() can free bio structure so we can't reference it after and G_RAID3_FOREACH_BIO() macro was doing this. Found by: Coverity Prevent analysis tool (with my new models) MFC after: 1 day --- sys/geom/raid3/g_raid3.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 04248b178931..e18497294b24 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -1009,7 +1009,7 @@ g_raid3_scatter(struct bio *pbp) { struct g_raid3_softc *sc; struct g_raid3_disk *disk; - struct bio *bp, *cbp; + struct bio *bp, *cbp, *tmpbp; off_t atom, cadd, padd, left; sc = pbp->bio_to->geom->softc; @@ -1038,8 +1038,6 @@ g_raid3_scatter(struct bio *pbp) cadd += atom; } if ((pbp->bio_pflags & G_RAID3_BIO_PFLAG_NOPARITY) == 0) { - struct bio *tmpbp; - /* * Calculate parity. */ @@ -1053,7 +1051,7 @@ g_raid3_scatter(struct bio *pbp) g_raid3_destroy_bio(sc, cbp); } } - G_RAID3_FOREACH_BIO(pbp, cbp) { + G_RAID3_FOREACH_SAFE_BIO(pbp, cbp, tmpbp) { struct g_consumer *cp; disk = cbp->bio_caller2; @@ -1685,7 +1683,7 @@ g_raid3_register_request(struct bio *pbp) struct g_raid3_softc *sc; struct g_raid3_disk *disk; struct g_consumer *cp; - struct bio *cbp; + struct bio *cbp, *tmpbp; off_t offset, length; u_int n, ndisks; int round_robin, verify; @@ -1831,7 +1829,7 @@ g_raid3_register_request(struct bio *pbp) */ sc->sc_round_robin = 0; } - G_RAID3_FOREACH_BIO(pbp, cbp) { + G_RAID3_FOREACH_SAFE_BIO(pbp, cbp, tmpbp) { disk = cbp->bio_caller2; cp = disk->d_consumer; cbp->bio_to = cp->provider;