Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 02/39] ALSA: sc6000: Fix the missing snd_card_free() call at probe error
Date: Tue, 12 Apr 2022 12:25:59 +0200	[thread overview]
Message-ID: <20220412102636.16000-3-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() on the error from the
probe callback using a new helper function.

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

diff --git a/sound/isa/sc6000.c b/sound/isa/sc6000.c
index 26ab7ff80768..60398fced046 100644
--- a/sound/isa/sc6000.c
+++ b/sound/isa/sc6000.c
@@ -537,7 +537,7 @@ static void snd_sc6000_free(struct snd_card *card)
 		sc6000_setup_board(vport, 0);
 }
 
-static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
+static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)
 {
 	static const int possible_irqs[] = { 5, 7, 9, 10, 11, -1 };
 	static const int possible_dmas[] = { 1, 3, 0, -1 };
@@ -662,6 +662,11 @@ static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
 	return 0;
 }
 
+static int snd_sc6000_probe(struct device *devptr, unsigned int dev)
+{
+	return snd_card_free_on_error(devptr, __snd_sc6000_probe(devptr, dev));
+}
+
 static struct isa_driver snd_sc6000_driver = {
 	.match		= snd_sc6000_match,
 	.probe		= snd_sc6000_probe,
-- 
2.31.1


  parent reply	other threads:[~2022-04-12 10:29 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 ` Takashi Iwai [this message]
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 ` [PATCH 32/39] ALSA: cmipci: " Takashi Iwai
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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox