Properly free resources in an error case.

CID:		4203
Found with:	Coverity Prevent(tm)
MFC after:	1 week
This commit is contained in:
Christian Brueffer 2011-10-15 15:57:55 +00:00
parent 2bd338d6c4
commit 0ad684e7b4

View File

@ -348,8 +348,10 @@ iicioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *t
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)
if (error) {
free(usrbufs, M_TEMP);
break;
}
/* Alloc kernel buffers for userland data, copyin write data */
for (i = 0; i < d->nmsgs; i++) {
m = &((struct iic_msg *)buf)[i];