Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Oct 2011 17:46:12 +0200
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Christian Brueffer <brueffer@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r226398 - head/sys/dev/iicbus
Message-ID:  <20111016154611.GA1832@garage.freebsd.pl>
In-Reply-To: <201110151557.p9FFvuuc020536@svn.freebsd.org>
References:  <201110151557.p9FFvuuc020536@svn.freebsd.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Sat, Oct 15, 2011 at 03:57:56PM +0000, Christian Brueffer wrote:
> Author: brueffer
> Date: Sat Oct 15 15:57:55 2011
> New Revision: 226398
> URL: http://svn.freebsd.org/changeset/base/226398
> 
> Log:
>   Properly free resources in an error case.
>   
>   CID:		4203
>   Found with:	Coverity Prevent(tm)
>   MFC after:	1 week
> 
> Modified:
>   head/sys/dev/iicbus/iic.c
> 
> Modified: head/sys/dev/iicbus/iic.c
> ==============================================================================
> --- head/sys/dev/iicbus/iic.c	Sat Oct 15 15:21:33 2011	(r226397)
> +++ head/sys/dev/iicbus/iic.c	Sat Oct 15 15:57:55 2011	(r226398)
> @@ -348,8 +348,10 @@ iicioctl(struct cdev *dev, u_long cmd, c
>  		buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_TEMP, M_WAITOK);
>  		usrbufs = malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITOK);
>  		error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs);
> -		if (error)
> +		if (error) {
> +			free(usrbufs, M_TEMP);
>  			break;
> +		}

I think that better fix is to move usrbufs allocation after copyin(), as
usrbufs is not used there.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk6a/EMACgkQForvXbEpPzRoewCgiEM/YOUQpHgZyfj3G/SJ7nnc
nW0AoL/Ec8dM5QzJW6NMFxgwfyM/QgCW
=X6L5
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111016154611.GA1832>