From nobody Wed Dec 17 03:59:53 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 --- 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