- 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
This commit is contained in:
Pawel Jakub Dawidek 2006-11-02 09:14:18 +00:00
parent 1506db2163
commit 41517ab2e9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163906

View File

@ -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;