From nobody Fri Jan 2 16:58:30 2026 X-Original-To: dev-commits-src-all@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 4djVJR32d8z6LvlD for ; Fri, 02 Jan 2026 16:58:31 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4djVJQ6HSXz42hc for ; Fri, 02 Jan 2026 16:58:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767373110; 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=2jDDZVrZPtQG26AkAdCgSVfIFYnW7A/NWVLuqMvthBk=; b=N405KxCLn+dov+hR9kmEDwteMEecymqli71Tib3vkqY5/tbWqqJm6Z0c1/2a+0ZgLqhbjQ hu9GY2e9X1l1nJpgatHCIyR57+pG26ZhAb8GK4kKBq0QMWPWcsTcGcctVtpc679A+jg9Nc 6EsQvh1n0b5nCIumPwcB1nT+plAg0MSkclwW7DKXVcPOpkQISLkeIML1JYM9nhoDNUw5JT wqV35t/5eqP/fk1RPwE8qreSbuQGQYZ/dBapKIOsRZ/UbdkvizxsMAmxiEEtFhv0AFiDSk UsQtKyk0KsKX3uIaOOiihty3Muy0W8mI24MM2p2xxPjVBQ5c05N8pQmRwxwY5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767373110; 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=2jDDZVrZPtQG26AkAdCgSVfIFYnW7A/NWVLuqMvthBk=; b=l+bVpc/1jgfT3LyTLBJrbttWi1E1SuDGA0zZHVmLI0+s1E+mbDfqhlAh+5FAcm7VIT2Oat AeJoV3BZ26N0gbdlz0QUeojPshmmNkYcvTRdQsm3i5l8jby1CVLkdKBmZQKfugiqMhpcQz jsnzXsoC4L32/gi27GmDrFw38nxqtxnhBep0YwKZY6xjmXsV1OvbrfQdHLw/MHnNlm0xbq +4g0u7rFpKAWRZzhcMEJX75vqGl3/sILbK/ks2ny58s7oeZsYNNxByNyoqx70cWd9H2nX6 U7XbVK0RclkQIbg7ddShuB/5ET4BOJhAqBYeCMHwBuqyVaH6Zz7dCZ1MG3aoKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767373110; a=rsa-sha256; cv=none; b=j/d/2bb8B667Qook6EUEpnkqvkqBQndzxXWq9okMfjtYr/Fc/Ema2IyhNmihRGBw6e4X2g 9wVYFkKlBuXqd1E5cFaA55T2j9Cs7TkYpnFLcJGCQiYIl+PHatbCN2loMujzV7bA2ff0ET ReQnfAO5k0Rf2xljV2yVa8D8Y143piEuOUGcWiWi3p061YzEcEnWP0GjbHv4t5P7jTjc/6 dduv8qScq+75Zyw1kDpi3Ig/23dK2gkb6Iq6Bg8VHF1Gc7Avbl6FYTci10CArxw+N6gMXX 03x+4vN93rtzOKS5jwx+v8IipLZo5XNqpX8Havar/gwZIjsbh/jAfEtrTvuZSQ== 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 4djVJQ5psTzBH4 for ; Fri, 02 Jan 2026 16:58:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24216 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 02 Jan 2026 16:58:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: b9db6c212873 - main - sound: Improve snd_midi->{in,out}q allocation List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org 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/main X-Git-Reftype: branch X-Git-Commit: b9db6c21287311b9e861893c065289d987a75804 Auto-Submitted: auto-generated Date: Fri, 02 Jan 2026 16:58:30 +0000 Message-Id: <6957f936.24216.3c7bcf3e@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b9db6c21287311b9e861893c065289d987a75804 commit b9db6c21287311b9e861893c065289d987a75804 Author: Christos Margiolis AuthorDate: 2026-01-02 16:56:34 +0000 Commit: Christos Margiolis CommitDate: 2026-01-02 16:58:06 +0000 sound: Improve snd_midi->{in,out}q allocation Currently we lock and allocate the buffers with M_NOWAIT, without checking if the return value of malloc(). This is not necessary as subsequent check below will eventually check that. However, for correctness, allocate the buffers with M_WAITOK (there is no reason not to) and lock afterwards. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D54131 --- sys/dev/sound/midi/midi.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index 9b61e972fab9..7f968b6210f5 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -109,7 +109,8 @@ midi_init(kobj_class_t cls, void *cookie) { struct snd_midi *m; int inqsize, outqsize; - uint8_t *buf; + uint8_t *ibuf = NULL; + uint8_t *obuf = NULL; m = malloc(sizeof(*m), M_MIDI, M_WAITOK | M_ZERO); kobj_init((kobj_t)m, cls); @@ -121,26 +122,17 @@ midi_init(kobj_class_t cls, void *cookie) mtx_init(&m->lock, "raw midi", NULL, 0); - mtx_lock(&m->lock); - if (inqsize) - buf = malloc(sizeof(uint8_t) * inqsize, M_MIDI, M_NOWAIT); - else - buf = NULL; + ibuf = malloc(inqsize, M_MIDI, M_WAITOK); + if (outqsize) + obuf = malloc(outqsize, M_MIDI, M_WAITOK); - MIDIQ_INIT(m->inq, buf, inqsize); + mtx_lock(&m->lock); - if (outqsize) - buf = malloc(sizeof(uint8_t) * outqsize, M_MIDI, M_NOWAIT); - else - buf = NULL; m->hiwat = outqsize / 2; - MIDIQ_INIT(m->outq, buf, outqsize); - - if ((inqsize && !MIDIQ_BUF(m->inq)) || - (outqsize && !MIDIQ_BUF(m->outq))) - goto err2; + MIDIQ_INIT(m->inq, ibuf, inqsize); + MIDIQ_INIT(m->outq, obuf, outqsize); m->flags = 0; m->unit = alloc_unr(dev_unr);