From d43bf55fc5457dd0b95f19ebbffcc8d8501ea157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Sewi=C5=82=C5=82o-Jopek?= Date: Fri, 28 Apr 2023 22:03:38 +0200 Subject: [PATCH] armv7: Fix BeagleBone Black panic on system start There is now assertion which requires all memory allocations of positive size. Negative and zero-sized allocations lead to panic, so plug them off. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D39846 --- sys/arm/ti/ti_sysc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/arm/ti/ti_sysc.c b/sys/arm/ti/ti_sysc.c index 2f6011e3049d..603dec3334c2 100644 --- a/sys/arm/ti/ti_sysc.c +++ b/sys/arm/ti/ti_sysc.c @@ -306,6 +306,9 @@ parse_regfields(struct ti_sysc_softc *sc) { /* Grab the content of reg properties */ nreg = OF_getproplen(node, "reg"); + if (nreg <= 0) + return (ENXIO); + reg = malloc(nreg, M_DEVBUF, M_WAITOK); OF_getencprop(node, "reg", reg, nreg);