Module Name:    src
Committed By:   thorpej
Date:           Sun Aug  8 01:06:57 UTC 2021

Modified Files:
        src/sys/dev/ofw [thorpej-i2c-spi-conf]: ofw_i2c_subr.c

Log Message:
If OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY, ensure that clist_size
is not negative for the call to kmem_tmpbuf_alloc().


To generate a diff of this commit:
cvs rdiff -u -r1.1.6.8 -r1.1.6.9 src/sys/dev/ofw/ofw_i2c_subr.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/ofw/ofw_i2c_subr.c
diff -u src/sys/dev/ofw/ofw_i2c_subr.c:1.1.6.8 src/sys/dev/ofw/ofw_i2c_subr.c:1.1.6.9
--- src/sys/dev/ofw/ofw_i2c_subr.c:1.1.6.8	Tue May 18 01:24:39 2021
+++ src/sys/dev/ofw/ofw_i2c_subr.c	Sun Aug  8 01:06:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_i2c_subr.c,v 1.1.6.8 2021/05/18 01:24:39 thorpej Exp $	*/
+/*	$NetBSD: ofw_i2c_subr.c,v 1.1.6.9 2021/08/08 01:06:57 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.6.8 2021/05/18 01:24:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_i2c_subr.c,v 1.1.6.9 2021/08/08 01:06:57 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -149,11 +149,13 @@ of_i2c_enumerate_devices(device_t dev, d
 		}
 
 		clist_size = OF_getproplen(node, "compatible");
-#ifndef OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY
 		if (clist_size <= 0) {
+#ifndef OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY
 			continue;
-		}
+#else
+			clist_size = 0;
 #endif
+		}
 		clist = kmem_tmpbuf_alloc(clist_size,
 		    compat_buf, sizeof(compat_buf), KM_SLEEP);
 		if (OF_getprop(node, "compatible", clist, clist_size) <

Reply via email to