Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Oct 2011 17:38:20 +0000 (UTC)
From:      Christian Brueffer <brueffer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226442 - head/sys/dev/iicbus
Message-ID:  <201110161738.p9GHcKFk072745@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brueffer
Date: Sun Oct 16 17:38:20 2011
New Revision: 226442
URL: http://svn.freebsd.org/changeset/base/226442

Log:
  Revert r226398 and instead move the allocation of usrbufs after the error check.
  
  Suggested by:	pjd
  MFC after:	1 week

Modified:
  head/sys/dev/iicbus/iic.c

Modified: head/sys/dev/iicbus/iic.c
==============================================================================
--- head/sys/dev/iicbus/iic.c	Sun Oct 16 17:37:54 2011	(r226441)
+++ head/sys/dev/iicbus/iic.c	Sun Oct 16 17:38:20 2011	(r226442)
@@ -346,13 +346,11 @@ iicioctl(struct cdev *dev, u_long cmd, c
 
 	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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110161738.p9GHcKFk072745>