Module Name:    src
Committed By:   martin
Date:           Fri Jan 23 09:50:36 UTC 2015

Modified Files:
        src/sys/dev/i2c [netbsd-7]: i2c.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #444):
        sys/dev/i2c/i2c.c: revision 1.46
More correctly handle I�C exec ioctls with both a command and write data
phase. Previously the data phase of ioctl writes was sending uninitialized
kernel stack to the addressed device.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/i2c/i2c.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.44 src/sys/dev/i2c/i2c.c:1.44.2.1
--- src/sys/dev/i2c/i2c.c:1.44	Fri Jul 25 08:10:37 2014
+++ src/sys/dev/i2c/i2c.c	Fri Jan 23 09:50:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: i2c.c,v 1.44 2014/07/25 08:10:37 dholland Exp $	*/
+/*	$NetBSD: i2c.c,v 1.44.2.1 2015/01/23 09:50:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.44 2014/07/25 08:10:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.44.2.1 2015/01/23 09:50:36 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -519,6 +519,13 @@ iic_ioctl_exec(struct iic_softc *sc, i2c
 		}
 	}
 
+	if (iie->iie_buf != NULL && I2C_OP_WRITE_P(iie->iie_op)) {
+		error = copyin(iie->iie_buf, buf, iie->iie_buflen);
+		if (error) {
+			return error;
+		}
+	}
+
 	iic_acquire_bus(ic, 0);
 	error = iic_exec(ic, iie->iie_op, iie->iie_addr, cmd, iie->iie_cmdlen,
 	    buf, iie->iie_buflen, 0);
@@ -536,7 +543,7 @@ iic_ioctl_exec(struct iic_softc *sc, i2c
 	if (error)
 		return error;
 
-	if (iie->iie_buf)
+	if (iie->iie_buf != NULL && I2C_OP_READ_P(iie->iie_op))
 		error = copyout(buf, iie->iie_buf, iie->iie_buflen);
 
 	return error;

Reply via email to