Module Name: src Committed By: riastradh Date: Mon Jan 29 18:55:51 UTC 2024
Modified Files: src/sys/dev/hdaudio: hdafg.c Log Message: hdaudio(4): Tighten hdafg_freem. The fix for PR kern/57890 in hdafg.c 1.29 included more conditionals than needed, covering cases that can't happen: if allocm returns null, audio(4) does not call freem; and if hdafg_allocm returns nonnull, then what audio(4) passes to hdafg_freem had better be either the playback or the capture buffer address. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/dev/hdaudio/hdafg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/hdaudio/hdafg.c diff -u src/sys/dev/hdaudio/hdafg.c:1.30 src/sys/dev/hdaudio/hdafg.c:1.31 --- src/sys/dev/hdaudio/hdafg.c:1.30 Tue Jul 18 13:35:57 2023 +++ src/sys/dev/hdaudio/hdafg.c Mon Jan 29 18:55:51 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.30 2023/07/18 13:35:57 riastradh Exp $ */ +/* $NetBSD: hdafg.c,v 1.31 2024/01/29 18:55:51 riastradh Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk> @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.30 2023/07/18 13:35:57 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.31 2024/01/29 18:55:51 riastradh Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -4282,15 +4282,12 @@ hdafg_freem(void *opaque, void *addr, si struct hdaudio_audiodev *ad = opaque; struct hdaudio_stream *st; - if (ad == NULL) - return; - if (ad->ad_playback != NULL && addr == DMA_KERNADDR(&ad->ad_playback->st_data)) st = ad->ad_playback; else if (ad->ad_capture != NULL && addr == DMA_KERNADDR(&ad->ad_capture->st_data)) st = ad->ad_capture; else - return; + panic("bad hdafg hwbuf mem: %p (%zu bytes)", addr, size); hdaudio_dma_free(st->st_host, &st->st_data); }