Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Free cmd on error if we allocated it.



details:   https://anonhg.NetBSD.org/src/rev/496e9834bccb
branches:  trunk
changeset: 337155:496e9834bccb
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Apr 04 15:14:42 2015 +0000

description:
Free cmd on error if we allocated it.

Found by Brainy, reported by maxv@.

diffstat:

 sys/dev/i2c/i2c.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r b8fb53465787 -r 496e9834bccb sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Sat Apr 04 15:12:39 2015 +0000
+++ b/sys/dev/i2c/i2c.c Sat Apr 04 15:14:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2c.c,v 1.46 2015/01/22 17:56:35 jakllsch Exp $        */
+/*     $NetBSD: i2c.c,v 1.47 2015/04/04 15:14:42 riastradh Exp $       */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.46 2015/01/22 17:56:35 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.47 2015/04/04 15:14:42 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -528,6 +528,8 @@
        if (iie->iie_buf != NULL && I2C_OP_WRITE_P(iie->iie_op)) {
                error = copyin(iie->iie_buf, buf, iie->iie_buflen);
                if (error) {
+                       if (cmd)
+                               kmem_free(cmd, iie->iie_cmdlen);
                        return error;
                }
        }



Home | Main Index | Thread Index | Old Index