diff mbox series

[26/39] ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error

Message ID 20220412102636.16000-27-tiwai@suse.de (mailing list archive)
State New, archived
Headers show
Series ALSA: Fix error handling order at probe error | expand

Commit Message

Takashi Iwai April 12, 2022, 10:26 a.m. UTC
The previous cleanup with devres may lead to the incorrect release
orders at the probe error handling due to the devres's nature.  Until
we register the card, snd_card_free() has to be called at first for
releasing the stuff properly when the driver tries to manage and
release the stuff via card->private_free().

This patch fixes it by calling snd_card_free() on the error from the
probe callback using a new helper function.

Fixes: 854577ac2aea ("ALSA: x86: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/x86/intel_hdmi_audio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

kernel test robot April 12, 2022, 5:14 p.m. UTC | #1
Hi Takashi,

I love your patch! Yet something to improve:

[auto build test ERROR on tiwai-sound/for-next]
[also build test ERROR on v5.18-rc2 next-20220412]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Takashi-Iwai/ALSA-Fix-error-handling-order-at-probe-error/20220412-183941
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: i386-randconfig-a016-20220411 (https://download.01.org/0day-ci/archive/20220413/202204130129.SNA1B1hM-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/9e76730fee819f96c44f07e9a100c907457aed8b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Takashi-Iwai/ALSA-Fix-error-handling-order-at-probe-error/20220412-183941
        git checkout 9e76730fee819f96c44f07e9a100c907457aed8b
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   sound/x86/intel_hdmi_audio.c: In function 'hdmi_lpe_audio_probe':
>> sound/x86/intel_hdmi_audio.c:1820:16: error: implicit declaration of function 'snd_card_free_on_error'; did you mean 'snd_ctl_free_one'? [-Werror=implicit-function-declaration]
    1820 |         return snd_card_free_on_error(&pdev->dev, __hdmi_lpe_audio_probe(pdev));
         |                ^~~~~~~~~~~~~~~~~~~~~~
         |                snd_ctl_free_one
   cc1: some warnings being treated as errors


vim +1820 sound/x86/intel_hdmi_audio.c

  1817	
  1818	static int hdmi_lpe_audio_probe(struct platform_device *pdev)
  1819	{
> 1820		return snd_card_free_on_error(&pdev->dev, __hdmi_lpe_audio_probe(pdev));
  1821	}
  1822
diff mbox series

Patch

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index b00634663346..0d828e35b401 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1652,7 +1652,7 @@  static void hdmi_lpe_audio_free(struct snd_card *card)
  * This function is called when the i915 driver creates the
  * hdmi-lpe-audio platform device.
  */
-static int hdmi_lpe_audio_probe(struct platform_device *pdev)
+static int __hdmi_lpe_audio_probe(struct platform_device *pdev)
 {
 	struct snd_card *card;
 	struct snd_intelhad_card *card_ctx;
@@ -1815,6 +1815,11 @@  static int hdmi_lpe_audio_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int hdmi_lpe_audio_probe(struct platform_device *pdev)
+{
+	return snd_card_free_on_error(&pdev->dev, __hdmi_lpe_audio_probe(pdev));
+}
+
 static const struct dev_pm_ops hdmi_lpe_audio_pm = {
 	SET_SYSTEM_SLEEP_PM_OPS(hdmi_lpe_audio_suspend, hdmi_lpe_audio_resume)
 };