From nobody Mon Apr 15 05:47:16 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 4VHx5K08wkz5Hpt2; Mon, 15 Apr 2024 05:47:17 +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 4VHx5J6jRpz4bb8; Mon, 15 Apr 2024 05:47:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713160036; 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=YhxB6gBRSswxocyVXE1Q5ogYAU2l6mQhN2YBnhGR+BY=; b=I58nXLno7PL8Tq9+2/OtoYeFDblAn/Av1Ggm/wiIymkoyk8vyA7yQfSjY9hvF8XsK7VtVp VhToFiOqVQhOYpiBbeBIgJXsGV16r5HNiNj5eRmAYou7msSCNn8avp/eXvV14Ozx2S7ORD Nmn3b/3vuuaf+V1GwXPUZqijVLHlbpzIU2wTLvmlxns+KQIYzH+fe7Gcke2vJ/njUubUvT Gmbj2tU4Gk+EMAPguhdNOt6LA3Zr00BT8TiGAJx2sjbFZGxNm1B21Gexy+SU8CGCJxaA6a bWapPca+EF1sVEE7H+zIY+Sc4m5037ynzroYe15WGo0AP0OO8uncFPGYfOPzwQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713160036; a=rsa-sha256; cv=none; b=Jq6rCJjq5Gl53WSA5+uaVgK7rr2N5pUUbdVRZfWJa0NqVGQ4jI51dVRHfEegGmvRTfJwAg orjiyHPU/07L2fCbJf9dxRSO8lMOGScMWkhGCrpdKRK+kaGlNgpYKdLmh6Z+567rMK+yok dcQvnNBGOv/1sVvKl43nbJRavisP1lrt/dv+/QApQbuW1qv1CAyPWAH8OQ2VF5OuqBN/Dg cGABX6u8jpsVAb6Do0ysTwjqvm9abCRX+egFKISuUhWtNKq/a2Sp6Yk7wyXqu/IvS0U+Kc z18ro2gIaSqNX/ABPMFA/3bSzhseiHF3m1XDi5h9beZ2CTC1ZCAl9wzHWuxrRA== 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=1713160036; 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=YhxB6gBRSswxocyVXE1Q5ogYAU2l6mQhN2YBnhGR+BY=; b=tNXRSwV6eXnFkLL9icwpyka+gRa01EKWeDeeH1N5dekitXAfec8dCxGtp2c5fhmUE5mDGu p+iADOJwJUMdL1qWVMkxL2L6psFL+GFp7EpIgoVMXA6Wbs7besrwRHyndp9vWi88hYCSuZ 0hO5kWmGitqFAJaRL6uLqcm5l1s90F9mDNMD4WlM3OIgRokGeDreO33npBWIX+QgIE6IE1 YuDAeFNjmMB+PCVMkfTbmqUq1mlGW+DC0NZ59tru0N3QQxn/ZmODXqqg/jQDQOsbn8C3ED ocTdlYW1hZYfm9Ba+hZFmiTE/UWH1FKINyzo6vwzKLhuWsHi/mza4u5TUhWygQ== 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 4VHx5J6K3DznGF; Mon, 15 Apr 2024 05:47:16 +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 43F5lG35019786; Mon, 15 Apr 2024 05:47:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43F5lG25019783; Mon, 15 Apr 2024 05:47:16 GMT (envelope-from git) Date: Mon, 15 Apr 2024 05:47:16 GMT Message-Id: <202404150547.43F5lG25019783@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Zhilin Subject: git: bed0b2146faa - main - 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 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/main X-Git-Reftype: branch X-Git-Commit: bed0b2146faa2e9a445d9f9196c7b46f50034631 Auto-Submitted: auto-generated The branch main has been updated by mizhka: URL: https://cgit.FreeBSD.org/src/commit/?id=bed0b2146faa2e9a445d9f9196c7b46f50034631 commit bed0b2146faa2e9a445d9f9196c7b46f50034631 Author: Michael Zhilin AuthorDate: 2024-04-13 09:59:24 +0000 Commit: Michael Zhilin CommitDate: 2024-04-15 05:46:43 +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 --- 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