summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2022-10-23 22:15:46 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2022-10-23 22:15:46 +0000
commitfa2bec0c4d23320eb8fc6fa3a689833dbdba7592 (patch)
treebeeb1ad2084d9d23bcf7df1c672eeefecc513676 /sys/arch
parent45b4666a028b3c85e06a27f84dc5cd0ea3ef15bd (diff)
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@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/dev/apldma.c4
1 files 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 <kettenis@openbsd.org>
*
@@ -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. */