svn commit: r226398 - head/sys/dev/iicbus
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sun Oct 16 17:21:16 UTC 2011
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
-------------- 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/svn-src-head/attachments/20111016/c2faf896/attachment.pgp
More information about the svn-src-head
mailing list