Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/dev/i2c Pull up following revision(s) (requested by j...



details:   https://anonhg.NetBSD.org/src/rev/eb328a2113ec
branches:  netbsd-7
changeset: 798885:eb328a2113ec
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Jan 23 09:50:36 2015 +0000

description:
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.

diffstat:

 sys/dev/i2c/i2c.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 79003d670713 -r eb328a2113ec sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Fri Jan 23 09:47:24 2015 +0000
+++ b/sys/dev/i2c/i2c.c Fri Jan 23 09:50:36 2015 +0000
@@ -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 @@
                }
        }
 
+       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 @@
        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;



Home | Main Index | Thread Index | Old Index