Date: Sun, 16 Oct 2011 19:20:28 +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: <20111016172028.GB1832@garage.freebsd.pl> In-Reply-To: <4E9B0CEE.7000809@FreeBSD.org> References: <201110151557.p9FFvuuc020536@svn.freebsd.org> <20111016154611.GA1832@garage.freebsd.pl> <4E9B0CEE.7000809@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--1UWUbFP1cBYEclgG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sun, Oct 16, 2011 at 06:57:18PM +0200, Christian Brueffer wrote:
> > I think that better fix is to move usrbufs allocation after copyin(), as
> > usrbufs is not used there.
> >
>=20
> Agreed, how about the attached patch?
Looks good.
> Index: 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
> --- iic.c (revision 226398)
> +++ iic.c (working copy)
> @@ -346,13 +346,11 @@
> =20
> case I2CRDWR:
> 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) {
> - free(usrbufs, M_TEMP);
> + if (error)
> break;
> - }
> /* Alloc kernel buffers for userland data, copyin write data */
> + usrbufs =3D malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITO=
K);
> for (i =3D 0; i < d->nmsgs; i++) {
> m =3D &((struct iic_msg *)buf)[i];
> usrbufs[i] =3D m->buf;
--=20
Pawel Jakub Dawidek http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://yomoli.com
--1UWUbFP1cBYEclgG
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)
iEYEARECAAYFAk6bElwACgkQForvXbEpPzQRBQCgmeXbugKIMbWQUNpiMxc/C/WK
c+0AnjflxBSwg7ugzEnRGK/lfcc/CEei
=dpbp
-----END PGP SIGNATURE-----
--1UWUbFP1cBYEclgG--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111016172028.GB1832>
