From nobody Fri Apr 19 06:57:35 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 4VLQSb4vHVz5J0Gx; Fri, 19 Apr 2024 06:57:35 +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 4VLQSb4MHfz4TMx; Fri, 19 Apr 2024 06:57:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713509855; 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=lBM615z3r0na/pToQ3fRUBYtubfTSeFYFYU84jVShgI=; b=rtDEgiXiYgaPPdI8qKUVntE5liXrE1cgPYpay4Dx7GuXVyMQroI84UevBJdb1MKjr4an/N IIagyI6A45tr3lv5+Po5Sqif1WCXwDfeJQl93qTAxOCz/eAgUXdP+8IimvzFW3VwFdBoHu Q79v+LiePaS6GpZgC/90ULCe2thCeN2qL4TBukDfOfLJo6xES35ol3FvqjnEhZhkj7/vDm mQ8KX8rbPtRApiHc8+ijKBmdvZjxl3v3gR2/WOkYWtYj0qEqhcGiifE5PR1tXjF5sEPYvt VkE9bzy+KoFVBtdB/wYcGaVdBt0RlSHZkxu+eDVnSc91OTWHwBbQr1LQwHZTZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713509855; a=rsa-sha256; cv=none; b=cp4FRB6SQ3zDla5dxVR8Qhl9UaWBKXJmF7NwPXxMTd1gKTazSNmSghOqDrYE7DAUW+aucc tNhWNxMfKTzU8Hihir5+1VyJDQhkRFAI+gL14a6N3Bnxrucy1mPGk+WNXqg1KneGHQrHaM g7DpFKkk6zqT9EVf3+5TULnhibYJNstPwyAIJIbla0i8lHtXM4yjGHxAqyE3fzIH/5kP7t DkI/9tG9GgNh5Utr2s03ZHc8EwwXgdwFHYTOcVEChOpXALhRB75nkomYIuYEC1Q4am6y6s caLC8Bvn58R0uVjyszd6zrKTI8qGQiOu1VATlz2kV8CJXNe4qJgRQQIpncB+Mw== 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=1713509855; 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=lBM615z3r0na/pToQ3fRUBYtubfTSeFYFYU84jVShgI=; b=I4CK9tea8Ghf4I960V73t5dXFrAXcf4dj5JZR38nL/hnkOe7Yaay8PccPwVbXcClD0oFQQ rOjwnUIjZOUCKuoT531nLyeY9P0VNYHTJ6dEjcGQz2zZ58F0er6344X1PozOjDBDaYZNN7 Uv66i1Add5OyU2KXkaFfzw2vqNOI5Ra2G5RaOqhDWoekiq3zPgtHPdtlXxu3LjI09YXlZi E5WsZOQ+5x4g6PFBblFekUDbJ8wMkYO88FVE3tBsV49NSs4s5SeaON+eeVIpMITm6KKakj 9ku87V/UHhBx/LthN4IrquQbpC/gPhG3NZsgSYiN5BGjHLlU0YZmu8UK+CJkUg== 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 4VLQSb3xYDzjjX; Fri, 19 Apr 2024 06:57:35 +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 43J6vZY6005781; Fri, 19 Apr 2024 06:57:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43J6vZnZ005778; Fri, 19 Apr 2024 06:57:35 GMT (envelope-from git) Date: Fri, 19 Apr 2024 06:57:35 GMT Message-Id: <202404190657.43J6vZnZ005778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Zhilin Subject: git: 2a66844f606a - stable/14 - snd_hda: fix "duplicated free" on module unloading 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: mizhka X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2a66844f606a35d68ad8a8061f4bea204274b3bc Auto-Submitted: auto-generated The branch stable/14 has been updated by mizhka: URL: https://cgit.FreeBSD.org/src/commit/?id=2a66844f606a35d68ad8a8061f4bea204274b3bc commit 2a66844f606a35d68ad8a8061f4bea204274b3bc Author: Michael Zhilin AuthorDate: 2024-04-13 09:59:24 +0000 Commit: Michael Zhilin CommitDate: 2024-04-19 06:37:08 +0000 snd_hda: fix "duplicated free" on module unloading This is trivial fix of hdacc_detach to avoid duplicated free on snd_hda unloading. The first try of detaching (kldunload) may results into "device busy" error, but codec->fgs is freed by detach. Second try attempts to free codec->fgs again and system panicks. Here is example: pcm0: unregister: channel pcm0:virtual:dsp0.vp0 busy (pid 3428) pulseaudio[3428] [oss] module-oss.c: DSP shutdown. pcm0: detached hdaa0: detached panic: Duplicate free of 0xfffff80412ee7d20 from zone 0xfffffe006bc0ba00 (malloc-32) slab 0xfffff80412ee7fc8(105) cpuid = 6 time = 1712999565 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0202f859e0 vpanic() at vpanic+0x135/frame 0xfffffe0202f85b10 panic() at panic+0x43/frame 0xfffffe0202f85b70 uma_dbg_free() at uma_dbg_free+0x105/frame 0xfffffe0202f85b90 uma_zfree_arg() at uma_zfree_arg+0x95/frame 0xfffffe0202f85be0 free() at free+0xa1/frame 0xfffffe0202f85c20 hdacc_detach() at hdacc_detach+0x2f/frame 0xfffffe0202f85c40 device_detach() at device_detach+0x197/frame 0xfffffe0202f85c80 devclass_driver_deleted() at devclass_driver_deleted+0x66/frame 0xfffffe0202f85c devclass_delete_driver() at devclass_delete_driver+0x81/frame 0xfffffe0202f85d00 driver_module_handler() at driver_module_handler+0xff/frame 0xfffffe0202f85d50 module_unload() at module_unload+0x32/frame 0xfffffe0202f85d70 linker_file_unload() at linker_file_unload+0x1eb/frame 0xfffffe0202f85db0 kern_kldunload() at kern_kldunload+0x18e/frame 0xfffffe0202f85e00 amd64_syscall() at amd64_syscall+0x153/frame 0xfffffe0202f85f30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe0202f85f30 MFC after: 3 days Reviewed by: markj, christos Differential Revision: https://reviews.freebsd.org/D44778 Sponsored by: Postgres Professional (cherry picked from commit bed0b2146faa2e9a445d9f9196c7b46f50034631) --- sys/dev/sound/pci/hda/hdacc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c index 123c64d9c487..009c9098ac3b 100644 --- a/sys/dev/sound/pci/hda/hdacc.c +++ b/sys/dev/sound/pci/hda/hdacc.c @@ -539,9 +539,10 @@ hdacc_detach(device_t dev) struct hdacc_softc *codec = device_get_softc(dev); int error; - error = device_delete_children(dev); + if ((error = device_delete_children(dev)) != 0) + return (error); free(codec->fgs, M_HDACC); - return (error); + return (0); } static int