From ba0f34826195f7102bbec2980b74c9d923b0228f Mon Sep 17 00:00:00 2001 From: pjd Date: Thu, 2 Nov 2006 09:14:18 +0000 Subject: - Use g_duplicate_bio() instead of g_clone_bio(), so there memory is allocated with M_WAITOK flag. - Check 'buf' instead of 'error' so Prevent is not confused. CID: 1562, 1563 Found by: Coverity Prevent analysis tool --- sys/geom/journal/g_journal.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sys/geom') diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index ad16e78..93293f9 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -600,11 +600,9 @@ g_journal_metadata_read(struct g_consumer *cp, struct g_journal_metadata *md) &error); g_topology_lock(); g_access(cp, -1, 0, 0); - if (error != 0) { + if (buf == NULL) { GJ_DEBUG(1, "Cannot read metadata from %s (error=%d).", cp->provider->name, error); - if (buf != NULL) - g_free(buf); return (error); } @@ -1622,7 +1620,7 @@ g_journal_read(struct g_journal_softc *sc, struct bio *pbp, off_t ostart, } if (bp != NULL) { if (bp->bio_data == NULL) { - nbp = g_clone_bio(pbp); + nbp = g_duplicate_bio(pbp); nbp->bio_cflags = GJ_BIO_READ; nbp->bio_data = pbp->bio_data + cstart - pbp->bio_offset; @@ -1646,7 +1644,7 @@ g_journal_read(struct g_journal_softc *sc, struct bio *pbp, off_t ostart, * Its time for asking data provider. */ GJ_DEBUG(3, "READ(data): (%jd, %jd)", ostart, oend); - nbp = g_clone_bio(pbp); + nbp = g_duplicate_bio(pbp); nbp->bio_cflags = GJ_BIO_READ; nbp->bio_data = pbp->bio_data + ostart - pbp->bio_offset; nbp->bio_offset = ostart; -- cgit v1.1