From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 05/39] ALSA: als4000: Fix the missing snd_card_free() call at probe error
Date: Tue, 12 Apr 2022 12:26:02 +0200 [thread overview]
Message-ID: <20220412102636.16000-6-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: 0e175f665960 ("ALSA: als4000: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/als4000.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index 535eccd124be..f33aeb692a11 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -806,8 +806,8 @@ static void snd_card_als4000_free( struct snd_card *card )
snd_als4000_free_gameport(acard);
}
-static int snd_card_als4000_probe(struct pci_dev *pci,
- const struct pci_device_id *pci_id)
+static int __snd_card_als4000_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
{
static int dev;
struct snd_card *card;
@@ -930,6 +930,12 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
return 0;
}
+static int snd_card_als4000_probe(struct pci_dev *pci,
+ const struct pci_device_id *pci_id)
+{
+ return snd_card_free_on_error(&pci->dev, __snd_card_als4000_probe(pci, pci_id));
+}
+
#ifdef CONFIG_PM_SLEEP
static int snd_als4000_suspend(struct device *dev)
{
--
2.31.1
next prev parent reply other threads:[~2022-04-12 10:28 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 ` Takashi Iwai [this message]
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-6-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