From nobody Sun Apr 28 19:49:00 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 4VSH8X58YBz5Jr2Y; Sun, 28 Apr 2024 19:49:00 +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 4VSH8X319Yz426s; Sun, 28 Apr 2024 19:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714333740; 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=dsa9ctrVmBYHj892MQalvDe3xKrPN3PkV7q/MAVt2kY=; b=DlT0B8kkj+Em+s4WEpNODSuD2Jtx1KBWQnQ7ltToISFpsnqptSn8FAuB5MY//vkIFm7o8m 3kPh24/KjKbc0VqJ9CDmRzfOws47gqJsfCoVlh1SE1mMXe3jWiW36LiTm1PQS4/CdBPyvH V1dqNFhJ3q5YmytjrxgVveaB8HwyQy29zx3WPqapltsNszOH4peJGjTWd+MCyS8NSq92u3 IH3YIgFxQUjd6YPv6G9G8Gy168tcrJ4XAF2crqRdQDZ5vEPugljH2SxqGok63Cg63POxsu j4IH1R/JIjWTS7pyX991aauvVELMYvWeVgxTtYKMp43duUxcpiiWjV4sLPRcHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714333740; a=rsa-sha256; cv=none; b=FuQyQpiwZl763SJwzYW1s2hEMHPJYAajh5j/sst2ImCpMiRcEqS+Y5tz2u988pWQLNJuEv 15AzcyvIk4q+oAvSm17pjL2GoEI/eP00l7qPE5u+NpYBY5X+HOk4GPRyxlOtSgCmxZ4SZY gF05LjEAlWiYoT86MQZN5eZ3+GL3o6snGPNs1jZh2lnPvDXuzJHVtfRY5r39bdT6pKNV0L yeF59UT14XwBy40b2bu1iZDXJfhCCNnjzYosim/J/CqhkLRV0WOr8PIo9+1C+hxj9l0Na+ R39VJz58sfdlx9goTKyI3czp8LVXL8GLakxGlZFntAvwHijgTXTtDXceQwKYVQ== 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=1714333740; 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=dsa9ctrVmBYHj892MQalvDe3xKrPN3PkV7q/MAVt2kY=; b=HRS+WuYHeism9S6QJTe0j+fqsKl4atTi+UYu/lzGWqx5M5btxBHkgQELR1tl+Nq2Mj2t9O qXlKuxIzFjYMpM7Jtyt8jiWncXuUrLRE/F2GWhtYcKZZqzUbwLsauWL206LsfB35gPPRo0 la6yIfyZFe8VmvVgk0aL9EiruIMgB/UR7bkb+6K3G6eG2C21Ainbt98eYeZ1skiXgT4Tvw e+iaNOdnINpJ97ZAMBaAltPz8TEGSw3EDnpa50K9/Va8eWWVotY+6rwNniqbEobEqp8s2D KgKV3K8WAs5N6bXjaemhAewfgsI57Wv3fb20rv0QHj24Pxx1948P8foU5R1Ggw== 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 4VSH8X2d4SzfJr; Sun, 28 Apr 2024 19:49:00 +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 43SJn02v063179; Sun, 28 Apr 2024 19:49:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43SJn0bF063176; Sun, 28 Apr 2024 19:49:00 GMT (envelope-from git) Date: Sun, 28 Apr 2024 19:49:00 GMT Message-Id: <202404281949.43SJn0bF063176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: b18b990d8e7b - main - 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/main X-Git-Reftype: branch X-Git-Commit: b18b990d8e7b15d25243d85ea22374dfdde8a18b Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=b18b990d8e7b15d25243d85ea22374dfdde8a18b commit b18b990d8e7b15d25243d85ea22374dfdde8a18b Author: Christos Margiolis AuthorDate: 2024-04-28 19:40:29 +0000 Commit: Christos Margiolis CommitDate: 2024-04-28 19:48:24 +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 --- 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 c5bb27530d2b..df1482d6a97a 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 33a7eb26606d..2f4a6f4d6395 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1377,12 +1377,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(); } }