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>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
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.
> >
>
> Agreed, how about the attached patch?
Looks good.
> Index: iic.c
> ===================================================================
> --- iic.c (revision 226398)
> +++ iic.c (working copy)
> @@ -346,13 +346,11 @@
>
> case I2CRDWR:
> 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) {
> - free(usrbufs, M_TEMP);
> + if (error)
> break;
> - }
> /* Alloc kernel buffers for userland data, copyin write data */
> + usrbufs = malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITOK);
> for (i = 0; i < d->nmsgs; i++) {
> m = &((struct iic_msg *)buf)[i];
> usrbufs[i] = m->buf;
--
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)
iEYEARECAAYFAk6bElwACgkQForvXbEpPzQRBQCgmeXbugKIMbWQUNpiMxc/C/WK
c+0AnjflxBSwg7ugzEnRGK/lfcc/CEei
=dpbp
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111016172028.GB1832>
