diff options
author | phk <phk@FreeBSD.org> | 2002-09-27 20:47:23 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-27 20:47:23 +0000 |
commit | 5002cfbb7eb2c253e16d44b1cb09d24e86fae96f (patch) | |
tree | cbf3960b54abc9b9f5fe0f6e11921ee7275428b2 | |
parent | 83aec680cb55261466c7d21ac999144f9985d59e (diff) | |
download | FreeBSD-src-5002cfbb7eb2c253e16d44b1cb09d24e86fae96f.zip FreeBSD-src-5002cfbb7eb2c253e16d44b1cb09d24e86fae96f.tar.gz |
Add checks for g_clone_bio() returning NULL, it will be possible RSN.
Sponsored by: DARPA & NAI Labs.
-rw-r--r-- | sys/geom/geom_aes.c | 12 | ||||
-rw-r--r-- | sys/geom/geom_slice.c | 7 |
2 files changed, 18 insertions, 1 deletions
diff --git a/sys/geom/geom_aes.c b/sys/geom/geom_aes.c index 70a8a85..4304c2d 100644 --- a/sys/geom/geom_aes.c +++ b/sys/geom/geom_aes.c @@ -195,12 +195,20 @@ g_aes_start(struct bio *bp) switch (bp->bio_cmd) { case BIO_READ: bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_fail(bp, ENOMEM); + return; + } bp2->bio_done = g_aes_read_done; bp2->bio_offset += sc->sectorsize; g_io_request(bp2, cp); break; case BIO_WRITE: bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_fail(bp, ENOMEM); + return; + } bp2->bio_done = g_aes_write_done; bp2->bio_offset += sc->sectorsize; bp2->bio_data = g_malloc(bp->bio_length, M_WAITOK); @@ -226,6 +234,10 @@ g_aes_start(struct bio *bp) if (g_handleattr_int(bp, "GEOM::sectorsize", sc->sectorsize)) return; bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_fail(bp, ENOMEM); + return; + } bp2->bio_done = g_std_done; bp2->bio_offset += sc->sectorsize; g_io_request(bp2, cp); diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index ab781d5..5bd20ea 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -72,7 +72,8 @@ g_slice_init(unsigned nslice, unsigned scsize) gsp = g_malloc(sizeof *gsp, M_WAITOK | M_ZERO); gsp->softc = g_malloc(scsize, M_WAITOK | M_ZERO); - gsp->slices = g_malloc(nslice * sizeof(struct g_slice), M_WAITOK | M_ZERO); + gsp->slices = g_malloc(nslice * sizeof(struct g_slice), + M_WAITOK | M_ZERO); gsp->nslice = nslice; return (gsp); } @@ -148,6 +149,10 @@ g_slice_start(struct bio *bp) return; } bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_fail(bp, ENOMEM); + return; + } if (bp2->bio_offset + bp2->bio_length > gsl->length) bp2->bio_length = gsl->length - bp2->bio_offset; bp2->bio_done = g_std_done; |