geli(4) memory leak

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Apr 2 10:45:05 UTC 2011


On Sat, Apr 02, 2011 at 12:04:09AM +0300, Mikolaj Golub wrote:
> For me your patch look correct. But the same issue is for read :-). Also, to
> avoid the leak I think we can just do g_destroy_bio() before "all sectors"
> check. See the attached patch (had some testing).

The patch looks good. Please commit.

> Index: sys/geom/eli/g_eli.c
> ===================================================================
> --- sys/geom/eli/g_eli.c	(revision 220168)
> +++ sys/geom/eli/g_eli.c	(working copy)
> @@ -160,13 +160,13 @@ g_eli_read_done(struct bio *bp)
>  	pbp = bp->bio_parent;
>  	if (pbp->bio_error == 0)
>  		pbp->bio_error = bp->bio_error;
> +	g_destroy_bio(bp);
>  	/*
>  	 * Do we have all sectors already?
>  	 */
>  	pbp->bio_inbed++;
>  	if (pbp->bio_inbed < pbp->bio_children)
>  		return;
> -	g_destroy_bio(bp);
>  	sc = pbp->bio_to->geom->softc;
>  	if (pbp->bio_error != 0) {
>  		G_ELI_LOGREQ(0, pbp, "%s() failed", __func__);
> @@ -202,6 +202,7 @@ g_eli_write_done(struct bio *bp)
>  		if (bp->bio_error != 0)
>  			pbp->bio_error = bp->bio_error;
>  	}
> +	g_destroy_bio(bp);
>  	/*
>  	 * Do we have all sectors already?
>  	 */
> @@ -215,7 +216,6 @@ g_eli_write_done(struct bio *bp)
>  		    pbp->bio_error);
>  		pbp->bio_completed = 0;
>  	}
> -	g_destroy_bio(bp);
>  	/*
>  	 * Write is finished, send it up.
>  	 */

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20110402/e43f904e/attachment.pgp


More information about the freebsd-stable mailing list