From 4e642e0ae9411d057f809d90b8d3e2d4f551487c Mon Sep 17 00:00:00 2001 From: tobhe Date: Sun, 23 Oct 2022 22:15:45 +0000 Subject: [PATCH] Make sure driver is attached before allocating a channel. Fixes a crash on M2 Macbook Air with a newer device tree where aplaudio tries to allocate a channel after apldma_attach() failed. ok kettenis@ --- sys/arch/arm64/dev/apldma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/dev/apldma.c b/sys/arch/arm64/dev/apldma.c index 8390003a3de..cf6107f8cef 100644 --- a/sys/arch/arm64/dev/apldma.c +++ b/sys/arch/arm64/dev/apldma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apldma.c,v 1.3 2022/10/12 11:29:53 jsg Exp $ */ +/* $OpenBSD: apldma.c,v 1.4 2022/10/23 22:15:45 tobhe Exp $ */ /* * Copyright (c) 2022 Mark Kettenis * @@ -259,7 +259,7 @@ apldma_alloc_channel(unsigned int chan) struct apldma_softc *sc = apldma_sc; struct apldma_channel *ac; - if (chan >= sc->sc_nchannels) + if (sc == NULL || chan >= sc->sc_nchannels) return NULL; /* We only support Tx channels for now. */ -- 2.20.1