From nobody Mon Apr 29 10:43:44 2024 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 4VSg0x1XvRz5J3DR; Mon, 29 Apr 2024 10:43:45 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VSg0w6sZ4z4p9x; Mon, 29 Apr 2024 10:43:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714387425; 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=He3VsJLU8GMQk790kCgIPhAAjbzdLGzO3IeMwGcg+EU=; b=k70hMG6V/igCWdOOAV6lfsdIovlPrH7gCLoQIGFzilC1+UXtOS4jZMVsd4x4V/fPCzunSt TSvV5XQr6ja1wMsT1KEdlWjoC3rPz5Bb5ZClvNXETZfCG869SCW3HDf6LyWu1+h3ZRLTKu RXNyDVMOhw2jUJudWdigJVgkQrmqu2zdENVp4SeD7CCXgFxPOipEr+NGTLXPVupk4IgKBg qSk0BONzUSzGMGZHLtxBRx+ReVk8w2t2A2SsMW70eGTk0LXbaFw0432vKCZD4UcyCbUQse 8yDT6nhPHi0G3yYi0HmxZuxShd15B4/nPgVC9KpKEKxix6TSJDLvcEjqtntrgQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714387425; a=rsa-sha256; cv=none; b=rRqBBCD9cggquwAbHfLgFREfjBYlEgejrpxFonaDENdKZeT6bCPv8gTWwuVV05Gdw3NJLj pls1qlQUqXPXHuHgWCqgABKzpwns05vhSFB17vUdcdBuPORIS+x+X8v6ZSlGcPi1oNL/Fe 5NhYjbj+JKhuGmBA+eXxny4/cTjvOlEskRJP/UC8pKoMf6a7nINvGx7WiR3UsPRizbfAI6 AYW/2AsHC7tkBO6RWi5CzMZTq9jNO7r7uqiXz4vSqGk2uIGCQ809gtBq7sWDK3JX8YW94c uLnOhPKmUodFcz/oyk3gPG/wnvj69PM4vkukdn5hq6zb7CfZHK0M7PhqH9p0nQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714387425; 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=He3VsJLU8GMQk790kCgIPhAAjbzdLGzO3IeMwGcg+EU=; b=VEwdfEZleSqGfjZHwwI58iGRyvOqCunu9tDsHHOa+iq4hnJQRAxya25DTP4Z44EJ6qrXWc 4R3n256ZNZ5xzPw2udLF1t868O8QBc0iJE4V9g9RMy+sZOpplYE+gj4z5BFQjF06eN6OVa o06dlNVsIcrFso1w1VvgEixKqj447/fCMqWTXSCNgxWqte/rMYZ+XNwjLRKVeYTu8P8ZT1 GHVqxjeODh/vowd3sJK322iCFogpshv4GmxfqRUfV69+IvNWje8hgf/cg51PJu1v2RhQy2 PMwGrkZwcV5CVyAf+oTZJ6rJqIlhM2BIXfCP46GqniG7lpmqLHT9uz8F2zzdSQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VSg0w6SDJz159h; Mon, 29 Apr 2024 10:43:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43TAhiS8088382; Mon, 29 Apr 2024 10:43:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43TAhiVl088379; Mon, 29 Apr 2024 10:43:44 GMT (envelope-from git) Date: Mon, 29 Apr 2024 10:43:44 GMT Message-Id: <202404291043.43TAhiVl088379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 9847c2497d2b - stable/14 - sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock() 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 9847c2497d2b5b5b1e956c6f565bf994358f545b Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=9847c2497d2b5b5b1e956c6f565bf994358f545b commit 9847c2497d2b5b5b1e956c6f565bf994358f545b Author: Christos Margiolis AuthorDate: 2024-04-28 19:40:29 +0000 Commit: Christos Margiolis CommitDate: 2024-04-29 10:43:30 +0000 sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock() Make sure that the softc isn't freed in between the checks. Sponsored by: The FreeBSD Foundation MFC after; 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44991 (cherry picked from commit b18b990d8e7b15d25243d85ea22374dfdde8a18b) --- sys/dev/sound/pcm/dsp.c | 2 ++ sys/dev/sound/pcm/mixer.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 20625641a601..aa6c21f36601 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -2085,6 +2085,7 @@ dsp_clone(void *arg, struct ucred *cred, char *name, int namelen, } return; found: + bus_topo_lock(); d = devclass_get_softc(pcm_devclass, snd_unit); /* * If we only have a single soundcard attached and we detach it right @@ -2096,6 +2097,7 @@ found: *dev = d->dsp_dev; dev_ref(*dev); } + bus_topo_unlock(); } static void diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index b84dfeba7043..0645089ac503 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1375,12 +1375,14 @@ mixer_clone(void *arg, if (*dev != NULL) return; if (strcmp(name, "mixer") == 0) { + bus_topo_lock(); d = devclass_get_softc(pcm_devclass, snd_unit); /* See related comment in dsp_clone(). */ if (d != NULL && PCM_REGISTERED(d) && d->mixer_dev != NULL) { *dev = d->mixer_dev; dev_ref(*dev); } + bus_topo_unlock(); } }