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
pgpLGcs71lg7n.pgp
Description: PGP signature
