All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 32/39] ALSA: cmipci: Fix the missing snd_card_free() call at probe error
Date: Tue, 12 Apr 2022 12:26:29 +0200	[thread overview]
Message-ID: <20220412102636.16000-33-tiwai@suse.de> (raw)
In-Reply-To: <20220412102636.16000-1-tiwai@suse.de>

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() manually on the error
from the probe callback.

Fixes: 87e082ad84a7 ("ALSA: cmipci: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/cmipci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index dab801d9d3b4..727db6d43391 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -3247,15 +3247,19 @@ static int snd_cmipci_probe(struct pci_dev *pci,
 
 	err = snd_cmipci_create(card, pci, dev);
 	if (err < 0)
-		return err;
+		goto error;
 
 	err = snd_card_register(card);
 	if (err < 0)
-		return err;
+		goto error;
 
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+ error:
+	snd_card_free(card);
+	return err;
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.31.1


  parent reply	other threads:[~2022-04-12 10:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
2022-04-12 10:25 ` [PATCH 01/39] ALSA: galaxy: Fix the missing snd_card_free() call " Takashi Iwai
2022-04-12 10:25 ` [PATCH 02/39] ALSA: sc6000: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 03/39] ALSA: ad1889: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 04/39] ALSA: ali5451: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 05/39] ALSA: als4000: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 06/39] ALSA: atiixp: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 07/39] ALSA: au88x0: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 08/39] ALSA: azt3328: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 09/39] ALSA: ca0106: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 10/39] ALSA: cs4281: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 11/39] ALSA: cs5535audio: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 12/39] ALSA: emu10k1x: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 13/39] ALSA: ens137x: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 14/39] ALSA: es1938: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 15/39] ALSA: es1968: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 16/39] ALSA: fm801: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 17/39] ALSA: ice1724: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 18/39] ALSA: intel8x0: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 19/39] ALSA: korg1212: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 20/39] ALSA: maestro3: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 21/39] ALSA: riptide: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 22/39] ALSA: rme32: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 23/39] ALSA: rme96: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 24/39] ALSA: sonicvibes: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 25/39] ALSA: via82xx: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 26/39] ALSA: intel_hdmi: " Takashi Iwai
2022-04-12 17:14   ` kernel test robot
2022-04-12 10:26 ` [PATCH 27/39] ALSA: sis7019: Fix the missing error handling Takashi Iwai
2022-04-12 10:26 ` [PATCH 28/39] ALSA: bt87x: Fix the missing snd_card_free() call at probe error Takashi Iwai
2022-04-12 10:26 ` [PATCH 29/39] ALSA: lola: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 30/39] ALSA: als300: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 31/39] ALSA: aw2: " Takashi Iwai
2022-04-12 10:26 ` Takashi Iwai [this message]
2022-04-12 10:26 ` [PATCH 33/39] ALSA: lx6464es: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 34/39] ALSA: oxygen: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 35/39] ALSA: hdsp: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 36/39] ALSA: hdspm: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 37/39] ALSA: rme9652: " Takashi Iwai
2022-04-12 10:26 ` [PATCH 38/39] ALSA: mtpav: Don't call card private_free at probe error path Takashi Iwai
2022-04-12 10:26 ` [PATCH 39/39] ALSA: nm256: " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220412102636.16000-33-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.