Source-Changes-HG archive

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

[src/thorpej-i2c-spi-conf]: src/sys/dev/ofw If OFW_I2C_ALLOW_MISSING_COMPATIB...



details:   https://anonhg.NetBSD.org/src/rev/74f8bee844fd
branches:  thorpej-i2c-spi-conf
changeset: 1020840:74f8bee844fd
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Aug 08 01:06:57 2021 +0000

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

diffstat:

 sys/dev/ofw/ofw_i2c_subr.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r 515912a06cf0 -r 74f8bee844fd sys/dev/ofw/ofw_i2c_subr.c
--- a/sys/dev/ofw/ofw_i2c_subr.c        Sun Aug 01 22:41:59 2021 +0000
+++ b/sys/dev/ofw/ofw_i2c_subr.c        Sun Aug 08 01:06:57 2021 +0000
@@ -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 @@
                }
 
                clist_size = OF_getproplen(node, "compatible");
+               if (clist_size <= 0) {
 #ifndef OFW_I2C_ALLOW_MISSING_COMPATIBLE_PROPERTY
-               if (clist_size <= 0) {
                        continue;
+#else
+                       clist_size = 0;
+#endif
                }
-#endif
                clist = kmem_tmpbuf_alloc(clist_size,
                    compat_buf, sizeof(compat_buf), KM_SLEEP);
                if (OF_getprop(node, "compatible", clist, clist_size) <



Home | Main Index | Thread Index | Old Index