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>

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

--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
>=20
> Log:
>   Properly free resources in an error case.
>  =20
>   CID:		4203
>   Found with:	Coverity Prevent(tm)
>   MFC after:	1 week
>=20
> Modified:
>   head/sys/dev/iicbus/iic.c
>=20
> Modified: head/sys/dev/iicbus/iic.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- 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 =3D malloc(sizeof(*d->msgs) * d->nmsgs, M_TEMP, M_WAITOK);
>  		usrbufs =3D malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITO=
K);
>  		error =3D 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.

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

--/04w6evG8XlLl3ft
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

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

--/04w6evG8XlLl3ft--



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