From: tobhe Date: Sun, 13 Feb 2022 16:44:50 +0000 (+0000) Subject: Fix return value check of OF_getproplen(). If "reset-gpios" is not found X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0eef8ed56ac27539d12909651d28ed2224f36ad7;p=openbsd Fix return value check of OF_getproplen(). If "reset-gpios" is not found in the device tree -1 is returned, causing a panic in the following malloc call. ok kn@ patrick@ kettenis@ --- diff --git a/sys/arch/armv7/marvell/mvpcie.c b/sys/arch/armv7/marvell/mvpcie.c index 3a7ac922b4c..673830853ae 100644 --- a/sys/arch/armv7/marvell/mvpcie.c +++ b/sys/arch/armv7/marvell/mvpcie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mvpcie.c,v 1.5 2021/10/24 17:52:27 mpi Exp $ */ +/* $OpenBSD: mvpcie.c,v 1.6 2022/02/13 16:44:50 tobhe Exp $ */ /* * Copyright (c) 2018 Patrick Wildt * Copyright (c) 2018 Mark Kettenis @@ -106,7 +106,7 @@ struct mvpcie_port { int po_fn; uint32_t *po_gpio; - size_t po_gpiolen; + int po_gpiolen; struct arm32_pci_chipset po_pc; int po_bus; @@ -353,7 +353,7 @@ mvpcie_port_attach(struct mvpcie_softc *sc, struct mvpcie_port *po, int node) po->po_bridge_iolimit = 1; po->po_gpiolen = OF_getproplen(po->po_node, "reset-gpios"); - if (po->po_gpiolen) { + if (po->po_gpiolen > 0) { po->po_gpio = malloc(po->po_gpiolen, M_DEVBUF, M_WAITOK); OF_getpropintarray(po->po_node, "reset-gpios", po->po_gpio, po->po_gpiolen);