From nobody Mon Sep 21 11:05:36 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hpL4K4ZKCz6rRc9 for ; Mon, 21 Sep 2026 11:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hpL4K0cr7z3Gyr for ; Mon, 21 Sep 2026 11:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789988737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Udza0zbx3Hszqaj71QazPSXY+MZxztqijF46c7UdAL8=; b=HeC3FUvhm798e4yw35dPSIi+XwcrCBOpT+Lt51WSYUEKp7HBidpGIzOWCkJLdTnBSrq9Df TQRRgEKG9deyKciJ933IyAv/wf0uHXTETrtZ+GROkNW8idbRbK71PM0uH/NJwxQF3NUWbR dtsvgFPE8jKLAmcesMcemwvTqrYZW/ToHmFNplYETSNJgm4L12PlSMhiiZm5nWXjwigVq0 gu602vZ+uNjtqSMXCcluH87WdNDsr4KEMY1O32DVkFXcKT8PK7Kg1KsWlN86maHshALTvm eZN4TH1sxei/nEbLqD6rvj5MTYZfE+KiLhmvCjaXCSPfHC3nEIbb/vtiyJEycw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789988737; b=e/mj/TyZtTla4aroYtDN+MZFgjCAqi2TBZ0fwalXa3jjzKPHr61q6iKZtN81ntW16WWSuP tpKAjNGO4BaJi0V0pNbSfY0US2IqpaDBlcUhllzO+m4fuo9ncyrKzH8WQCE4nBfvk34wBI s+NPMF+I9sTWqAWSuMNDcE9nHw6/7nRNd0G20gxzO4UPBI0AwvmnDGyv2n4nlcOpKsQr9O ZpgAUwnXDWGyzzK0/18Wx+higjNWt2keTmcuasVLLU4eB0IsR2ziGuyNkm217k5yLBCc5N 8Umm0ms9zYeT62/T92dMSZLTFljf2H4wSyMsdYp9bqeXRTzTOcK8pn/uJ+HuLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789988737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Udza0zbx3Hszqaj71QazPSXY+MZxztqijF46c7UdAL8=; b=qV6Y9TUEcT9jd0FxyUCcLtUQs4wWxqhZG+HG4wxXwV2uRT3zqAze0Lcp/74ppLveuszjzo k2ATbj8JhwbeNswMmxtv/cJOv2jzUVSP8QKbkkdEVzSmshwrVF+oLpxBC1xtTCsfRhLVH6 qXdb6ir5vwqWcONiSuqOrkbbAzmgzZoXHN5ivAonTvD1WZr/kewz0ZlfVePrd215LHvSio x5pHJwfNv0U77FizqVitcJ2ql+HeH+UWKCSRKQCmrH2A/ZM3WcMKz2K8f452paKFxbgfQx cz7G1tTT9HVpH30dSc3duE58ocQKmb6Bp2RFYsQgLAuW066x8+6nGEe/ymoloQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hpL4J4FDCzHkF for ; Mon, 21 Sep 2026 11:05:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 336eb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 21 Sep 2026 11:05:36 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: a4ea046d3843 - stable/15 - snd_hdsp*: malloc(9) with M_WAITOK List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a4ea046d384306b71d71031e94da3bb4f23a26dc Auto-Submitted: auto-generated Date: Mon, 21 Sep 2026 11:05:36 +0000 Message-Id: <6ab10f80.336eb.4cf3ae0c@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=a4ea046d384306b71d71031e94da3bb4f23a26dc commit a4ea046d384306b71d71031e94da3bb4f23a26dc Author: Christos Margiolis AuthorDate: 2026-08-22 12:48:50 +0000 Commit: Christos Margiolis CommitDate: 2026-09-21 11:04:08 +0000 snd_hdsp*: malloc(9) with M_WAITOK Perform the allocations outside the lock section so that we can use M_WAITOK. Holding the lock here is actually not really necessary and we could just as well remove it, but keep it for consistency. Sponsored by: The FreeBSD Foundation MFC after: 1 month Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D59079 (cherry picked from commit b5c1ab6c8f2811278b801084713a6618f3b783d3) --- sys/dev/sound/pci/hdsp-pcm.c | 17 +++++++++++++++-- sys/dev/sound/pci/hdspe-pcm.c | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/pci/hdsp-pcm.c b/sys/dev/sound/pci/hdsp-pcm.c index b4df8ca90555..7f4f7dc76557 100644 --- a/sys/dev/sound/pci/hdsp-pcm.c +++ b/sys/dev/sound/pci/hdsp-pcm.c @@ -676,10 +676,13 @@ hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct sc_pcminfo *scp; struct sc_chinfo *ch; struct sc_info *sc; + struct pcmchan_caps *caps; + uint32_t *data; int num; scp = devinfo; sc = scp->sc; + caps = malloc(sizeof(struct pcmchan_caps), M_HDSP, M_WAITOK); mtx_lock(&sc->lock); num = scp->chnum; @@ -704,7 +707,7 @@ hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, SND_FORMAT(AFMT_S32_LE, hdsp_port_slot_count(ch->ports, 192000), 0); ch->cap_fmts[3] = 0; - ch->caps = malloc(sizeof(struct pcmchan_caps), M_HDSP, M_NOWAIT); + ch->caps = caps; *(ch->caps) = (struct pcmchan_caps) {32000, 192000, ch->cap_fmts, 0}; /* HDSP 9652 does not support quad speed sample rates. */ @@ -715,7 +718,6 @@ hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, /* Allocate maximum buffer size. */ ch->size = HDSP_CHANBUF_SIZE * hdsp_port_slot_count_max(ch->ports); - ch->data = malloc(ch->size, M_HDSP, M_NOWAIT); ch->position = 0; ch->buffer = b; @@ -726,6 +728,17 @@ hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, mtx_unlock(&sc->lock); + /* + * It is safe to access ch->size here without holding the lock, because + * 1) as of now, ch->size is written only once, here, and 2) ch's + * lifetime is equal to scp's lifetime so it cannot go away yet. + */ + data = malloc(ch->size, M_HDSP, M_WAITOK); + + mtx_lock(&sc->lock); + ch->data = data; + mtx_unlock(&sc->lock); + if (sndbuf_setup(ch->buffer, ch->data, ch->size) != 0) { device_printf(scp->dev, "Can't setup sndbuf.\n"); hdspchan_free(obj, ch); diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c index e0b6168efcba..a814c80127b1 100644 --- a/sys/dev/sound/pci/hdspe-pcm.c +++ b/sys/dev/sound/pci/hdspe-pcm.c @@ -670,10 +670,13 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct sc_pcminfo *scp; struct sc_chinfo *ch; struct sc_info *sc; + struct pcmchan_caps *caps; + uint32_t *data; int num; scp = devinfo; sc = scp->sc; + caps = malloc(sizeof(struct pcmchan_caps), M_HDSPE, M_WAITOK); mtx_lock(&sc->lock); num = scp->chnum; @@ -697,12 +700,11 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, ch->cap_fmts[2] = SND_FORMAT(AFMT_S32_LE, hdspe_channel_count(ch->ports, 8), 0); ch->cap_fmts[3] = 0; - ch->caps = malloc(sizeof(struct pcmchan_caps), M_HDSPE, M_NOWAIT); + ch->caps = caps; *(ch->caps) = (struct pcmchan_caps) {32000, 192000, ch->cap_fmts, 0}; /* Allocate maximum buffer size. */ ch->size = HDSPE_CHANBUF_SIZE * hdspe_channel_count(ch->ports, 8); - ch->data = malloc(ch->size, M_HDSPE, M_NOWAIT); ch->position = 0; ch->buffer = b; @@ -713,6 +715,17 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, mtx_unlock(&sc->lock); + /* + * It is safe to access ch->size here without holding the lock, because + * 1) as of now, ch->size is written only once, here, and 2) ch's + * lifetime is equal to scp's lifetime so it cannot go away yet. + */ + data = malloc(ch->size, M_HDSPE, M_WAITOK); + + mtx_lock(&sc->lock); + ch->data = data; + mtx_unlock(&sc->lock); + if (sndbuf_setup(ch->buffer, ch->data, ch->size) != 0) { device_printf(scp->dev, "Can't setup sndbuf.\n"); hdspechan_free(obj, ch);