Module Name:    src
Committed By:   riastradh
Date:           Sat Apr  4 15:14:42 UTC 2015

Modified Files:
        src/sys/dev/i2c: i2c.c

Log Message:
Free cmd on error if we allocated it.

Found by Brainy, reported by maxv@.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/dev/i2c/i2c.c:1.47
--- src/sys/dev/i2c/i2c.c:1.46	Thu Jan 22 17:56:35 2015
+++ src/sys/dev/i2c/i2c.c	Sat Apr  4 15:14:42 2015
@@ -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 @@ 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) {
+			if (cmd)
+				kmem_free(cmd, iie->iie_cmdlen);
 			return error;
 		}
 	}

Reply via email to