diff options
author | brueffer <brueffer@FreeBSD.org> | 2011-10-16 17:38:20 +0000 |
---|---|---|
committer | brueffer <brueffer@FreeBSD.org> | 2011-10-16 17:38:20 +0000 |
commit | 1767d076f90b5748534ec5da2528deaae9011917 (patch) | |
tree | 051db78898c87d9e03ea661b04c378ef76297a22 | |
parent | c3b6325d6f44ae4a6bcd494fc00d74d39204c8a0 (diff) | |
download | FreeBSD-src-1767d076f90b5748534ec5da2528deaae9011917.zip FreeBSD-src-1767d076f90b5748534ec5da2528deaae9011917.tar.gz |
Revert r226398 and instead move the allocation of usrbufs after the error check.
Suggested by: pjd
MFC after: 1 week
-rw-r--r-- | sys/dev/iicbus/iic.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/dev/iicbus/iic.c b/sys/dev/iicbus/iic.c index 54668c4..d251555 100644 --- a/sys/dev/iicbus/iic.c +++ b/sys/dev/iicbus/iic.c @@ -346,13 +346,11 @@ iicioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t 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; |