From nobody Mon Sep 15 11:12:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93BA6C54EBC for ; Thu, 12 Jan 2023 11:37:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235929AbjALLhe (ORCPT ); Thu, 12 Jan 2023 06:37:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbjALLgV (ORCPT ); Thu, 12 Jan 2023 06:36:21 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C330B10073 for ; Thu, 12 Jan 2023 03:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522918; x=1705058918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C4Q7t6S4036xeiDu5xxCUyx970NCpXYQ7LpyZ8TZ13k=; b=OQwuQRuAI0oWu1tRqs5zY9WFfeOvyt1YYsO/qZPnMQ6tWN7Vd2FjsvE3 L1h22ULXqTeYCYW89EaPM31TDr25kHpJFXSV0VuiRYCw1g2HT1SLszSB9 NxZjKztg3YE+0khNAsTvBTXc3TuCzE+u9Bpm4zvb/C5rRzCXP7pheURqo KS9y5rBbUWBXGRWRuJn7l624MuDoy25zD2uKA5SeGJZxyJBkRbs1QgDyv JuF/dOKzIbyDxhylOUYxZ5zwx7z0zjn7rBmSLPQWqeu6Swhm532mejl1t cvIxS3U6ISHKlWqBr1XmomwutV+IeAKovUedATPZL3LsHSEB/c/t8bpfB g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994962" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994962" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519418" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519418" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 72458E1; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Subject: [PATCH v2 1/5] ASoC: Intel: bytcht_es8316: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:48 +0200 Message-Id: <20230112112852.67714-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: 3c22a73fb873 ("ASoC: Intel: bytcht_es8316: fix HID handling") Signed-off-by: Andy Shevchenko Acked-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcht_es8316.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/boards/bytcht_es8316.c b/sound/soc/intel/board= s/bytcht_es8316.c index 09d1f0f6d686..df157b01df8b 100644 --- a/sound/soc/intel/boards/bytcht_es8316.c +++ b/sound/soc/intel/boards/bytcht_es8316.c @@ -497,21 +497,28 @@ static int snd_byt_cht_es8316_mc_probe(struct platfor= m_device *pdev) if (adev) { snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_cht_es8316_dais[dai_index].codecs->name =3D codec_name; } else { dev_err(dev, "Error cannot find '%s' dev\n", mach->id); return -ENXIO; } =20 + codec_dev =3D acpi_get_first_physical_node(adev); + acpi_dev_put(adev); + if (!codec_dev) + return -EPROBE_DEFER; + priv->codec_dev =3D get_device(codec_dev); + /* override platform name, if required */ byt_cht_es8316_card.dev =3D dev; platform_name =3D mach->mach_params.platform; =20 ret =3D snd_soc_fixup_dai_links_platform_name(&byt_cht_es8316_card, platform_name); - if (ret) + if (ret) { + put_device(codec_dev); return ret; + } =20 /* Check for BYTCR or other platform and setup quirks */ dmi_id =3D dmi_first_match(byt_cht_es8316_quirk_table); @@ -539,13 +546,10 @@ static int snd_byt_cht_es8316_mc_probe(struct platfor= m_device *pdev) =20 /* get the clock */ priv->mclk =3D devm_clk_get(dev, "pmc_plt_clk_3"); - if (IS_ERR(priv->mclk)) + if (IS_ERR(priv->mclk)) { + put_device(codec_dev); return dev_err_probe(dev, PTR_ERR(priv->mclk), "clk_get pmc_plt_clk_3 fa= iled\n"); - - codec_dev =3D acpi_get_first_physical_node(adev); - if (!codec_dev) - return -EPROBE_DEFER; - priv->codec_dev =3D get_device(codec_dev); + } =20 if (quirk & BYT_CHT_ES8316_JD_INVERTED) props[cnt++] =3D PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); --=20 2.39.0 From nobody Mon Sep 15 11:12:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05608C54EBD for ; Thu, 12 Jan 2023 11:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235456AbjALLhT (ORCPT ); Thu, 12 Jan 2023 06:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjALLgG (ORCPT ); Thu, 12 Jan 2023 06:36:06 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A694FAC8 for ; Thu, 12 Jan 2023 03:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522911; x=1705058911; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vjV8y8LbzUXQrt45Puugictbqi3QHzP5bvn2L0BGWt0=; b=STtktRarbQuzNVOUnZPlKjpufgLYeumQxHaNeEGI7sbA/ZdABTh6uZR3 G1agI7ENEq1+0MBbsx43ryAvXWQpKu8gYi6tKwpIvEtjoKgM/UJP2d5Lp Vruv/LC6gUWkahjkrO9sLuManiLWTRp3H2JheP73iM1CQNpWqMbN4U3Ad nKV/YncOediac8+svJWrtMXUTGIPKK6X3RdV9YVJDFfXUNP4QE04AszTk 9eSrgthKa7CVBRMQ4BorgssxMcsIkigQHCngNSk3eilKsa8ahgv7vpon2 akb2WnJwduXGddq4TTu+zylxYEgBYs5ULdLM0BOEUQewPvfr2bbQPK4cI g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994942" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994942" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519423" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519423" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7C04B14B; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Subject: [PATCH v2 2/5] ASoC: Intel: bytcr_rt5651: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:49 +0200 Message-Id: <20230112112852.67714-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: 02c0a3b3047f ("ASoC: Intel: bytcr_rt5651: add MCLK, quirks and clean= ups") Signed-off-by: Andy Shevchenko Acked-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards= /bytcr_rt5651.c index 81ac6eeda2e6..8fca9b82d4d0 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -922,7 +922,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_devi= ce *pdev) if (adev) { snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_rt5651_dais[dai_index].codecs->name =3D byt_rt5651_codec_name; } else { dev_err(dev, "Error cannot find '%s' dev\n", mach->id); @@ -930,6 +929,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_devi= ce *pdev) } =20 codec_dev =3D acpi_get_first_physical_node(adev); + acpi_dev_put(adev); if (!codec_dev) return -EPROBE_DEFER; priv->codec_dev =3D get_device(codec_dev); --=20 2.39.0 From nobody Mon Sep 15 11:12:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABE61C54EBC for ; Thu, 12 Jan 2023 11:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbjALLhX (ORCPT ); Thu, 12 Jan 2023 06:37:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbjALLgR (ORCPT ); Thu, 12 Jan 2023 06:36:17 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44B2FCEF for ; Thu, 12 Jan 2023 03:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522913; x=1705058913; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BrwpZf0Qi8AA+i94wAgY34Wsc5QpYESR4OVN/jMXpfw=; b=iViLhaW3V5/17PQ6MYY8OqWw0t289rwZZmLTzSz+i4ovuWBnQWg7Jl0y aRYQzq7DDCVoPRHZGB3oN+HbX8Zwp/M1Njn+RBdrAI+d17I6Va2v/ZtoO jYfDj6stPS06CcNvJW+OJU3hsOffng24FR747ncy33A0FKdR8wrAc1WaM YSenvDKqSkVyXl9ucllARarf5tfYyaIYU3qnEoSU8Ws7XrW+OTT4V/fkn yIYU+BXBzhAEPz089bdW3xkAPeQsnzY6pAYlnQ6KxfU82EFRDbUgRipAO YuxhrMelGLF2FsIHHylJDLm6q0x+HjCK+rNprlGg3FZd1sW1jj02nxmIG A==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994955" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994955" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519424" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519424" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8AF4831D; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Subject: [PATCH v2 3/5] ASoC: Intel: bytcr_rt5640: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:50 +0200 Message-Id: <20230112112852.67714-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: a232b96dcece ("ASoC: Intel: bytcr_rt5640: use HID translation util") Signed-off-by: Andy Shevchenko Acked-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards= /bytcr_rt5640.c index 4699ca79f3ea..79e0039c79a3 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -1636,13 +1636,18 @@ static int snd_byt_rt5640_mc_probe(struct platform_= device *pdev) if (adev) { snprintf(byt_rt5640_codec_name, sizeof(byt_rt5640_codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); byt_rt5640_dais[dai_index].codecs->name =3D byt_rt5640_codec_name; } else { dev_err(dev, "Error cannot find '%s' dev\n", mach->id); return -ENXIO; } =20 + codec_dev =3D acpi_get_first_physical_node(adev); + acpi_dev_put(adev); + if (!codec_dev) + return -EPROBE_DEFER; + priv->codec_dev =3D get_device(codec_dev); + /* * swap SSP0 if bytcr is detected * (will be overridden if DMI quirk is detected) @@ -1717,11 +1722,6 @@ static int snd_byt_rt5640_mc_probe(struct platform_d= evice *pdev) byt_rt5640_quirk =3D quirk_override; } =20 - codec_dev =3D acpi_get_first_physical_node(adev); - if (!codec_dev) - return -EPROBE_DEFER; - priv->codec_dev =3D get_device(codec_dev); - if (byt_rt5640_quirk & BYT_RT5640_JD_HP_ELITEP_1000G2) { acpi_dev_add_driver_gpios(ACPI_COMPANION(priv->codec_dev), byt_rt5640_hp_elitepad_1000g2_gpios); --=20 2.39.0 From nobody Mon Sep 15 11:12:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7277FC54EBC for ; Thu, 12 Jan 2023 11:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236336AbjALLhn (ORCPT ); Thu, 12 Jan 2023 06:37:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbjALLgW (ORCPT ); Thu, 12 Jan 2023 06:36:22 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3DF101CB for ; Thu, 12 Jan 2023 03:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522919; x=1705058919; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9CUFrPQ09yPzbbj4IV4mmL6zJucv2gUZLtx+M2adKnU=; b=TpmvVMDAOyFLwEVQbRjWSukeGtX6lwIV/Ver0B5nICbGH/H5yVTExlCe BbjMbwU0J4ZvI6G8cLZ+PJloXsKYaCPz5O1M6tmEvQysMyCin8iqw4maL kUMHC1agz2c6fkxa5B+TH5xA6/24P6B47JnR+DPWEnKPl39ZNuwJmh7UC CEZxK/4x9bmyH9d3ZlVu+vWCQDHQwwhG6ezg0ypZYf/xUhpOC6W1+YEyg Om8SRQ5Fp0YA8sPyqa34k4mKhDKLDPoTJW2gtgUH9/fh0PL/zdIVBPeva jpXVvNIox3ED9ErABF1OdSjKviuc+JmO4LDOC/NKGH6dIshK2IFsMGHV0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="385994966" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="385994966" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="986519420" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="986519420" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 12 Jan 2023 03:28:22 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 95AFE330; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Subject: [PATCH v2 4/5] ASoC: Intel: bytcr_wm5102: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:51 +0200 Message-Id: <20230112112852.67714-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: 9a87fc1e0619 ("ASoC: Intel: bytcr_wm5102: Add machine driver for BYT= /WM5102") Signed-off-by: Andy Shevchenko Acked-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bytcr_wm5102.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcr_wm5102.c b/sound/soc/intel/boards= /bytcr_wm5102.c index 1669eb3bd80f..c0706537f673 100644 --- a/sound/soc/intel/boards/bytcr_wm5102.c +++ b/sound/soc/intel/boards/bytcr_wm5102.c @@ -411,9 +411,9 @@ static int snd_byt_wm5102_mc_probe(struct platform_devi= ce *pdev) return -ENOENT; } snprintf(codec_name, sizeof(codec_name), "spi-%s", acpi_dev_name(adev)); - put_device(&adev->dev); =20 codec_dev =3D bus_find_device_by_name(&spi_bus_type, NULL, codec_name); + acpi_dev_put(adev); if (!codec_dev) return -EPROBE_DEFER; =20 --=20 2.39.0 From nobody Mon Sep 15 11:12:04 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A3E7C54EBC for ; Thu, 12 Jan 2023 11:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbjALLhM (ORCPT ); Thu, 12 Jan 2023 06:37:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235496AbjALLf6 (ORCPT ); Thu, 12 Jan 2023 06:35:58 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09663E099 for ; Thu, 12 Jan 2023 03:28:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673522910; x=1705058910; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jhd+WRzaHqmWRkPNRNir7nTbOsn0RTp6sg9bQRKKJuM=; b=Q6VkXtGkUr0v2L3z/BGLTeID0BBo7fMFPShPl7HCwZDpQXQoyE7fkw4O ZLESLm7M2aiMCG2d4DpvhQ0nDf1BrFRMEoj2x/lAdyQLxnVlCY41ESAE6 WbsqeOXbxCwUsGI+aSGUq7pyhire3XCIKoGpqalAFSwfziSmsAGm9Dm1n CzHPImKZFEs+5/AMXAZbptoMWVljgD3397QNg10OGs0BHUxbi18bUUfB2 Q9qYsXD3io9bJGjqQe/uI1IN4s240YHNYV6xKyYWhboZ4Fu5ebLp+tFDv SqxDXTPVR5rvmWf7cdyMed2sLzqR6nbYuJftr3uYZkOXTJT3xq+S86WC1 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="304058541" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="304058541" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 03:28:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="903164798" X-IronPort-AV: E=Sophos;i="5.96,319,1665471600"; d="scan'208";a="903164798" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 12 Jan 2023 03:28:27 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A03854E3; Thu, 12 Jan 2023 13:28:56 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Hans de Goede , Pierre-Louis Bossart , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Cezary Rojewski , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Kai Vehmanen , Jaroslav Kysela , Takashi Iwai , Andy Shevchenko Subject: [PATCH v2 5/5] ASoC: Intel: sof_es8336: Drop reference count of ACPI device after use Date: Thu, 12 Jan 2023 13:28:52 +0200 Message-Id: <20230112112852.67714-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> References: <20230112112852.67714-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Theoretically the device might gone if its reference count drops to 0. This might be the case when we try to find the first physical node of the ACPI device. We need to keep reference to it until we get a result of the above mentioned call. Refactor the code to drop the reference count at the correct place. While at it, move to acpi_dev_put() as symmetrical call to the acpi_dev_get_first_match_dev(). Fixes: a164137ce91a ("ASoC: Intel: add machine driver for SOF+ES8336") Signed-off-by: Andy Shevchenko Acked-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_es8336.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/sof_es8336.c b/sound/soc/intel/boards/s= of_es8336.c index 773e5d1d87d4..894b6610b9e2 100644 --- a/sound/soc/intel/boards/sof_es8336.c +++ b/sound/soc/intel/boards/sof_es8336.c @@ -681,7 +681,6 @@ static int sof_es8336_probe(struct platform_device *pde= v) if (adev) { snprintf(codec_name, sizeof(codec_name), "i2c-%s", acpi_dev_name(adev)); - put_device(&adev->dev); dai_links[0].codecs->name =3D codec_name; =20 /* also fixup codec dai name if relevant */ @@ -692,16 +691,19 @@ static int sof_es8336_probe(struct platform_device *p= dev) return -ENXIO; } =20 - ret =3D snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, - mach->mach_params.platform); - if (ret) - return ret; - codec_dev =3D acpi_get_first_physical_node(adev); + acpi_dev_put(adev); if (!codec_dev) return -EPROBE_DEFER; priv->codec_dev =3D get_device(codec_dev); =20 + ret =3D snd_soc_fixup_dai_links_platform_name(&sof_es8336_card, + mach->mach_params.platform); + if (ret) { + put_device(codec_dev); + return ret; + } + if (quirk & SOF_ES8336_JD_INVERTED) props[cnt++] =3D PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); =20 --=20 2.39.0