From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 282DDC05027 for ; Mon, 23 Jan 2023 08:12:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E25D741E9; Mon, 23 Jan 2023 09:11:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E25D741E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1674461566; bh=EVWKKjHZGKYUMuQ/Hq80WIQqWOQljIbB0QkcubI5wE8=; h=Date:From:To:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=mieUMUw/DrPCOF9ZKDsZQvg9PBeMFYiCEGosSQa01nyOMDGeMpxKKw6JGN7uIu4ik iTZLat3+ha25hLoBNfH7kpt8rvyk22/gGmuQbGSFSZWEbtTtXIzzr+vBmhelyf2lIt /jlvLh6o5SIjfZI42+qyNcuuvpC3d81mUyoS9gEs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9BF66F804C2; Mon, 23 Jan 2023 09:11:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 08EF8F800FB; Mon, 23 Jan 2023 09:11:55 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 76D2CF800FB for ; Mon, 23 Jan 2023 09:11:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 76D2CF800FB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=T8Y8frbC; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+cVp2IwI Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 13F601F385; Mon, 23 Jan 2023 08:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674461511; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=d/F6NvY7PQRwJWUMaY7EZrImgYwgt5pp7gp/HblNSXA=; b=T8Y8frbC9v8rSRTuV5uuXVSp+z9OtX0bwnECMhve/MC0aHnrZy4lm/CScFzQtmtdyUpp2X dxZ6MrU3ItiKTJw+TzJfFxP/Y6BHVrMMUZXQvipDEW9IZkvPpit6aun8vxJHUa8q1EsZi2 fpqCbBiqCr364p0BMNFnGuu799ETRC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674461511; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=d/F6NvY7PQRwJWUMaY7EZrImgYwgt5pp7gp/HblNSXA=; b=+cVp2IwIKAJWBtH5VB7lP0Af2ryThWS7Fs+ZuNgtFn9nk/1rpPbyY6fLxsfRR++wW9Dvb3 Y9IxC1FjBthrGIBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CB0EF1357F; Mon, 23 Jan 2023 08:11:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oX+dMEZBzmNoSgAAMHmgww (envelope-from ); Mon, 23 Jan 2023 08:11:50 +0000 Date: Mon, 23 Jan 2023 09:11:50 +0100 Message-ID: <874jshr7p5.wl-tiwai@suse.de> From: Takashi Iwai To: Cezary Rojewski Subject: Re: [PATCH v2] ALSA: hda: Do not unset preset when cleaning up codec In-Reply-To: <20230119143235.1159814-1-cezary.rojewski@intel.com> References: <20230119143235.1159814-1-cezary.rojewski@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, amadeuszx.slawinski@linux.intel.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, 19 Jan 2023 15:32:35 +0100, Cezary Rojewski wrote: > > Several functions that take part in codec's initialization and removal > are re-used by ASoC codec drivers implementations. Drivers mimic the > behavior of hda_codec_driver_probe/remove() found in > sound/pci/hda/hda_bind.c with their component->probe/remove() instead. > > One of the reasons for that is the expectation of > snd_hda_codec_device_new() to receive a valid pointer to an instance of > struct snd_card. This expectation can be met only once sound card > components probing commences. > > As ASoC sound card may be unbound without codec device being actually > removed from the system, unsetting ->preset in > snd_hda_codec_cleanup_for_unbind() interferes with module unload -> load > scenario causing null-ptr-deref. Preset is assigned only once, during > device/driver matching whereas ASoC codec driver's module reloading may > occur several times throughout the lifetime of an audio stack. > > Suggested-by: Takashi Iwai > Signed-off-by: Cezary Rojewski > --- > > Changes in v2: > - relocated the operation to routines found in hda_bind.c rather than > just removing it from the cleanup function > > > This is a continuation of a discussion that begun in the middle of 2022 > [1] and was part of a larger series addressing several HDAudio topics. > > Single rmmod on ASoC's codec driver module is enough to cause a panic. > Given our results, no regression shows up with modprobe/rmmod on > snd_hda_intel side with this patch applied. > > [1]: https://lore.kernel.org/alsa-devel/20220706120230.427296-2-cezary.rojewski@intel.com/ Thanks, applied now. Takashi