All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/39] ALSA: Fix error handling order at probe error
@ 2022-04-12 10:25 Takashi Iwai
  2022-04-12 10:25 ` [PATCH 01/39] ALSA: galaxy: Fix the missing snd_card_free() call " Takashi Iwai
                   ` (38 more replies)
  0 siblings, 39 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:25 UTC (permalink / raw)
  To: alsa-devel

Hi,

this is a bunch of additional fixes that are similar like the previous
patch set for echoaudio but applied to other drivers that suffer from
the very same issue -- the incorrect error handling order at the
probe error.

Most of patches just follow the same strategy, the use of the new
snd_card_free_on_error() helper while some few took just the manual
snd_card_free() call and some with shuffling the private_free setup
for avoiding the problem.


Takashi

===

Takashi Iwai (39):
  ALSA: galaxy: Fix the missing snd_card_free() call at probe error
  ALSA: sc6000: Fix the missing snd_card_free() call at probe error
  ALSA: ad1889: Fix the missing snd_card_free() call at probe error
  ALSA: ali5451: Fix the missing snd_card_free() call at probe error
  ALSA: als4000: Fix the missing snd_card_free() call at probe error
  ALSA: atiixp: Fix the missing snd_card_free() call at probe error
  ALSA: au88x0: Fix the missing snd_card_free() call at probe error
  ALSA: azt3328: Fix the missing snd_card_free() call at probe error
  ALSA: ca0106: Fix the missing snd_card_free() call at probe error
  ALSA: cs4281: Fix the missing snd_card_free() call at probe error
  ALSA: cs5535audio: Fix the missing snd_card_free() call at probe error
  ALSA: emu10k1x: Fix the missing snd_card_free() call at probe error
  ALSA: ens137x: Fix the missing snd_card_free() call at probe error
  ALSA: es1938: Fix the missing snd_card_free() call at probe error
  ALSA: es1968: Fix the missing snd_card_free() call at probe error
  ALSA: fm801: Fix the missing snd_card_free() call at probe error
  ALSA: ice1724: Fix the missing snd_card_free() call at probe error
  ALSA: intel8x0: Fix the missing snd_card_free() call at probe  error
  ALSA: korg1212: Fix the missing snd_card_free() call at probe  error
  ALSA: maestro3: Fix the missing snd_card_free() call at probe error
  ALSA: riptide: Fix the missing snd_card_free() call at probe error
  ALSA: rme32: Fix the missing snd_card_free() call at probe error
  ALSA: rme96: Fix the missing snd_card_free() call at probe error
  ALSA: sonicvibes: Fix the missing snd_card_free() call at probe error
  ALSA: via82xx: Fix the missing snd_card_free() call at probe error
  ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error
  ALSA: sis7019: Fix the missing error handling
  ALSA: bt87x: Fix the missing snd_card_free() call at probe error
  ALSA: lola: Fix the missing snd_card_free() call at probe error
  ALSA: als300: Fix the missing snd_card_free() call at probe error
  ALSA: aw2: Fix the missing snd_card_free() call at probe error
  ALSA: cmipci: Fix the missing snd_card_free() call at probe error
  ALSA: lx6464es: Fix the missing snd_card_free() call at probe error
  ALSA: oxygen: Fix the missing snd_card_free() call at probe error
  ALSA: hdsp: Fix the missing snd_card_free() call at probe error
  ALSA: hdspm: Fix the missing snd_card_free() call at probe error
  ALSA: rme9652: Fix the missing snd_card_free() call at probe error
  ALSA: mtpav: Don't call card private_free at probe error path
  ALSA: nm256: Don't call card private_free at probe error path

 sound/drivers/mtpav.c               |  4 ++--
 sound/isa/galaxy/galaxy.c           |  7 ++++++-
 sound/isa/sc6000.c                  |  7 ++++++-
 sound/pci/ad1889.c                  | 10 ++++++++--
 sound/pci/ali5451/ali5451.c         | 10 ++++++++--
 sound/pci/als300.c                  |  8 ++++++--
 sound/pci/als4000.c                 | 10 ++++++++--
 sound/pci/atiixp.c                  | 10 ++++++++--
 sound/pci/atiixp_modem.c            | 10 ++++++++--
 sound/pci/au88x0/au88x0.c           |  8 +++++++-
 sound/pci/aw2/aw2-alsa.c            |  8 ++++++--
 sound/pci/azt3328.c                 |  8 +++++++-
 sound/pci/bt87x.c                   | 10 ++++++++--
 sound/pci/ca0106/ca0106_main.c      | 10 ++++++++--
 sound/pci/cmipci.c                  |  8 ++++++--
 sound/pci/cs4281.c                  | 10 ++++++++--
 sound/pci/cs5535audio/cs5535audio.c | 10 ++++++++--
 sound/pci/emu10k1/emu10k1x.c        | 10 ++++++++--
 sound/pci/ens1370.c                 | 10 ++++++++--
 sound/pci/es1938.c                  | 10 ++++++++--
 sound/pci/es1968.c                  | 10 ++++++++--
 sound/pci/fm801.c                   | 10 ++++++++--
 sound/pci/ice1712/ice1724.c         | 10 ++++++++--
 sound/pci/intel8x0.c                | 10 ++++++++--
 sound/pci/intel8x0m.c               | 10 ++++++++--
 sound/pci/korg1212/korg1212.c       |  8 ++++++--
 sound/pci/lola/lola.c               | 10 ++++++++--
 sound/pci/lx6464es/lx6464es.c       |  8 ++++++--
 sound/pci/maestro3.c                |  8 +++++++-
 sound/pci/nm256/nm256.c             |  2 +-
 sound/pci/oxygen/oxygen_lib.c       | 12 +++++++++++-
 sound/pci/riptide/riptide.c         |  8 +++++++-
 sound/pci/rme32.c                   |  8 +++++++-
 sound/pci/rme96.c                   | 10 ++++++++--
 sound/pci/rme9652/hdsp.c            |  8 ++++++--
 sound/pci/rme9652/hdspm.c           |  8 ++++++--
 sound/pci/rme9652/rme9652.c         |  8 ++++++--
 sound/pci/sis7019.c                 | 14 ++++++++++----
 sound/pci/sonicvibes.c              | 10 ++++++++--
 sound/pci/via82xx.c                 | 10 ++++++++--
 sound/pci/via82xx_modem.c           | 10 ++++++++--
 sound/x86/intel_hdmi_audio.c        |  7 ++++++-
 42 files changed, 301 insertions(+), 76 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH 01/39] ALSA: galaxy: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
@ 2022-04-12 10:25 ` Takashi Iwai
  2022-04-12 10:25 ` [PATCH 02/39] ALSA: sc6000: " Takashi Iwai
                   ` (37 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:25 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/isa/galaxy/galaxy.c b/sound/isa/galaxy/galaxy.c
index ea001c80149d..3164eb8510fa 100644
--- a/sound/isa/galaxy/galaxy.c
+++ b/sound/isa/galaxy/galaxy.c
@@ -478,7 +478,7 @@ static void snd_galaxy_free(struct snd_card *card)
 		galaxy_set_config(galaxy, galaxy->config);
 }
 
-static int snd_galaxy_probe(struct device *dev, unsigned int n)
+static int __snd_galaxy_probe(struct device *dev, unsigned int n)
 {
 	struct snd_galaxy *galaxy;
 	struct snd_wss *chip;
@@ -598,6 +598,11 @@ static int snd_galaxy_probe(struct device *dev, unsigned int n)
 	return 0;
 }
 
+static int snd_galaxy_probe(struct device *dev, unsigned int n)
+{
+	return snd_card_free_on_error(dev, __snd_galaxy_probe(dev, n));
+}
+
 static struct isa_driver snd_galaxy_driver = {
 	.match		= snd_galaxy_match,
 	.probe		= snd_galaxy_probe,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 02/39] ALSA: sc6000: Fix the missing snd_card_free() call at probe error
  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
  2022-04-12 10:26 ` [PATCH 03/39] ALSA: ad1889: " Takashi Iwai
                   ` (36 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:25 UTC (permalink / raw)
  To: alsa-devel

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


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 03/39] ALSA: ad1889: Fix the missing snd_card_free() call at probe error
  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 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 04/39] ALSA: ali5451: " Takashi Iwai
                   ` (35 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 567f58754109 ("ALSA: ad1889: Allocate resources with device-managed APIs")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ad1889.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index bba4dae8dcc7..50e30704bf6f 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -844,8 +844,8 @@ snd_ad1889_create(struct snd_card *card, struct pci_dev *pci)
 }
 
 static int
-snd_ad1889_probe(struct pci_dev *pci,
-		 const struct pci_device_id *pci_id)
+__snd_ad1889_probe(struct pci_dev *pci,
+		   const struct pci_device_id *pci_id)
 {
 	int err;
 	static int devno;
@@ -904,6 +904,12 @@ snd_ad1889_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_ad1889_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_ad1889_probe(pci, pci_id));
+}
+
 static const struct pci_device_id snd_ad1889_ids[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_ANALOG_DEVICES, PCI_DEVICE_ID_AD1889JS) },
 	{ 0, },
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 04/39] ALSA: ali5451: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (2 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 03/39] ALSA: ad1889: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 05/39] ALSA: als4000: " Takashi Iwai
                   ` (34 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

The recent 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: 1f0819979248 ("ALSA: ali5451: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ali5451/ali5451.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 92eb59db106d..2378a39abaeb 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -2124,8 +2124,8 @@ static int snd_ali_create(struct snd_card *card,
 	return 0;
 }
 
-static int snd_ali_probe(struct pci_dev *pci,
-			 const struct pci_device_id *pci_id)
+static int __snd_ali_probe(struct pci_dev *pci,
+			   const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct snd_ali *codec;
@@ -2170,6 +2170,12 @@ static int snd_ali_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_ali_probe(struct pci_dev *pci,
+			 const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_ali_probe(pci, pci_id));
+}
+
 static struct pci_driver ali5451_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_ali_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 05/39] ALSA: als4000: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (3 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 04/39] ALSA: ali5451: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 06/39] ALSA: atiixp: " Takashi Iwai
                   ` (33 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 06/39] ALSA: atiixp: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (4 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 05/39] ALSA: als4000: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 07/39] ALSA: au88x0: " Takashi Iwai
                   ` (32 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 86bde74dbf09 ("ALSA: atiixp: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/atiixp.c       | 10 ++++++++--
 sound/pci/atiixp_modem.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index b8e035d5930d..43d01f1847ed 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1572,8 +1572,8 @@ static int snd_atiixp_init(struct snd_card *card, struct pci_dev *pci)
 }
 
 
-static int snd_atiixp_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_atiixp_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct atiixp *chip;
@@ -1623,6 +1623,12 @@ static int snd_atiixp_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_atiixp_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_atiixp_probe(pci, pci_id));
+}
+
 static struct pci_driver atiixp_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_atiixp_ids,
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 178dce8ef1e9..8864c4c3c7e1 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1201,8 +1201,8 @@ static int snd_atiixp_init(struct snd_card *card, struct pci_dev *pci)
 }
 
 
-static int snd_atiixp_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_atiixp_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct atiixp_modem *chip;
@@ -1247,6 +1247,12 @@ static int snd_atiixp_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_atiixp_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_atiixp_probe(pci, pci_id));
+}
+
 static struct pci_driver atiixp_modem_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_atiixp_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 07/39] ALSA: au88x0: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (5 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 06/39] ALSA: atiixp: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 08/39] ALSA: azt3328: " Takashi Iwai
                   ` (31 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: e44b5b440609 ("ALSA: au88x0: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/au88x0/au88x0.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 342ef2a6655e..eb234153691b 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -193,7 +193,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci)
 
 // constructor -- see "Constructor" sub-section
 static int
-snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+__snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -310,6 +310,12 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 	return 0;
 }
 
+static int
+snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_vortex_probe(pci, pci_id));
+}
+
 // pci_driver definition
 static struct pci_driver vortex_driver = {
 	.name = KBUILD_MODNAME,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 08/39] ALSA: azt3328: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (6 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 07/39] ALSA: au88x0: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 09/39] ALSA: ca0106: " Takashi Iwai
                   ` (30 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 8c5823ef31e1 ("ALSA: azt3328: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/azt3328.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 089050470ff2..7f329dfc5404 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -2427,7 +2427,7 @@ snd_azf3328_create(struct snd_card *card,
 }
 
 static int
-snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+__snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2520,6 +2520,12 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 	return 0;
 }
 
+static int
+snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_azf3328_probe(pci, pci_id));
+}
+
 #ifdef CONFIG_PM_SLEEP
 static inline void
 snd_azf3328_suspend_regs(const struct snd_azf3328 *chip,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 09/39] ALSA: ca0106: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (7 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 08/39] ALSA: azt3328: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 10/39] ALSA: cs4281: " Takashi Iwai
                   ` (29 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 1656fa6ea258 ("ALSA: ca0106: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ca0106/ca0106_main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 8577f9fa5ea6..cf1bac7a435f 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1725,8 +1725,8 @@ static int snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel)
 }
 
 
-static int snd_ca0106_probe(struct pci_dev *pci,
-					const struct pci_device_id *pci_id)
+static int __snd_ca0106_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1786,6 +1786,12 @@ static int snd_ca0106_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_ca0106_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_ca0106_probe(pci, pci_id));
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int snd_ca0106_suspend(struct device *dev)
 {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 10/39] ALSA: cs4281: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (8 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 09/39] ALSA: ca0106: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 11/39] ALSA: cs5535audio: " Takashi Iwai
                   ` (28 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 99041fea70d0 ("ALSA: cs4281: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/cs4281.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index e7367402b84a..0c9cadf7b3b8 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1827,8 +1827,8 @@ static void snd_cs4281_opl3_command(struct snd_opl3 *opl3, unsigned short cmd,
 	spin_unlock_irqrestore(&opl3->reg_lock, flags);
 }
 
-static int snd_cs4281_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_cs4281_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1888,6 +1888,12 @@ static int snd_cs4281_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_cs4281_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_cs4281_probe(pci, pci_id));
+}
+
 /*
  * Power Management
  */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 11/39] ALSA: cs5535audio: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (9 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 10/39] ALSA: cs4281: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 12/39] ALSA: emu10k1x: " Takashi Iwai
                   ` (27 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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().

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

diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index 499fa0148f9a..440b8f9b40c9 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -281,8 +281,8 @@ static int snd_cs5535audio_create(struct snd_card *card,
 	return 0;
 }
 
-static int snd_cs5535audio_probe(struct pci_dev *pci,
-				 const struct pci_device_id *pci_id)
+static int __snd_cs5535audio_probe(struct pci_dev *pci,
+				   const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -331,6 +331,12 @@ static int snd_cs5535audio_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_cs5535audio_probe(struct pci_dev *pci,
+				 const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_cs5535audio_probe(pci, pci_id));
+}
+
 static struct pci_driver cs5535audio_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_cs5535audio_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 12/39] ALSA: emu10k1x: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (10 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 11/39] ALSA: cs5535audio: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 13/39] ALSA: ens137x: " Takashi Iwai
                   ` (26 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 2b377c6b6012 ("ALSA: emu10k1x: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/emu10k1/emu10k1x.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index c49c44dc1082..89043392f3ec 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -1491,8 +1491,8 @@ static int snd_emu10k1x_midi(struct emu10k1x *emu)
 	return 0;
 }
 
-static int snd_emu10k1x_probe(struct pci_dev *pci,
-			      const struct pci_device_id *pci_id)
+static int __snd_emu10k1x_probe(struct pci_dev *pci,
+				const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1554,6 +1554,12 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_emu10k1x_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_emu10k1x_probe(pci, pci_id));
+}
+
 // PCI IDs
 static const struct pci_device_id snd_emu10k1x_ids[] = {
 	{ PCI_VDEVICE(CREATIVE, 0x0006), 0 },	/* Dell OEM version (EMU10K1) */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 13/39] ALSA: ens137x: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (11 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 12/39] ALSA: emu10k1x: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 14/39] ALSA: es1938: " Takashi Iwai
                   ` (25 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 10ed6eaf9d72 ("ALSA: ens137x: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ens1370.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 2651f0c64c06..94efe347a97a 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2304,8 +2304,8 @@ static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int snd_audiopci_probe(struct pci_dev *pci,
-			      const struct pci_device_id *pci_id)
+static int __snd_audiopci_probe(struct pci_dev *pci,
+				const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2369,6 +2369,12 @@ static int snd_audiopci_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_audiopci_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_audiopci_probe(pci, pci_id));
+}
+
 static struct pci_driver ens137x_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_audiopci_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 14/39] ALSA: es1938: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (12 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 13/39] ALSA: ens137x: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 15/39] ALSA: es1968: " Takashi Iwai
                   ` (24 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 08e9d3ab4cc1 ("ALSA: es1938: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/es1938.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 00b976f42a3d..e34ec6f89e7e 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1716,8 +1716,8 @@ static int snd_es1938_mixer(struct es1938 *chip)
 }
        
 
-static int snd_es1938_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_es1938_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1796,6 +1796,12 @@ static int snd_es1938_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_es1938_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id));
+}
+
 static struct pci_driver es1938_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_es1938_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 15/39] ALSA: es1968: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (13 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 14/39] ALSA: es1938: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 16/39] ALSA: fm801: " Takashi Iwai
                   ` (23 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: a7b4cbfdc701 ("ALSA: es1968: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/es1968.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 6a8a02a9ecf4..4a7e20bb11bc 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2741,8 +2741,8 @@ static int snd_es1968_create(struct snd_card *card,
 
 /*
  */
-static int snd_es1968_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_es1968_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2848,6 +2848,12 @@ static int snd_es1968_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_es1968_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_es1968_probe(pci, pci_id));
+}
+
 static struct pci_driver es1968_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_es1968_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 16/39] ALSA: fm801: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (14 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 15/39] ALSA: es1968: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 17/39] ALSA: ice1724: " Takashi Iwai
                   ` (22 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 47c413395376 ("ALSA: fm801: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/fm801.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 9c22ff19e56d..62b3cb126c6d 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1268,8 +1268,8 @@ static int snd_fm801_create(struct snd_card *card,
 	return 0;
 }
 
-static int snd_card_fm801_probe(struct pci_dev *pci,
-				const struct pci_device_id *pci_id)
+static int __snd_card_fm801_probe(struct pci_dev *pci,
+				  const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1333,6 +1333,12 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_card_fm801_probe(struct pci_dev *pci,
+				const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_card_fm801_probe(pci, pci_id));
+}
+
 #ifdef CONFIG_PM_SLEEP
 static const unsigned char saved_regs[] = {
 	FM801_PCM_VOL, FM801_I2S_VOL, FM801_FM_VOL, FM801_REC_SRC,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 17/39] ALSA: ice1724: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (15 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 16/39] ALSA: fm801: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 18/39] ALSA: intel8x0: " Takashi Iwai
                   ` (21 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 314f6dbb1f33 ("ALSA: ice1724: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/ice1712/ice1724.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index f6275868877a..6fab2ad85bbe 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2519,8 +2519,8 @@ static int snd_vt1724_create(struct snd_card *card,
  *
  */
 
-static int snd_vt1724_probe(struct pci_dev *pci,
-			    const struct pci_device_id *pci_id)
+static int __snd_vt1724_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2662,6 +2662,12 @@ static int snd_vt1724_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_vt1724_probe(struct pci_dev *pci,
+			    const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_vt1724_probe(pci, pci_id));
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int snd_vt1724_suspend(struct device *dev)
 {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 18/39] ALSA: intel8x0: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (16 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 17/39] ALSA: ice1724: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 19/39] ALSA: korg1212: " Takashi Iwai
                   ` (20 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 7835e0901e24 ("ALSA: intel8x0: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/intel8x0.c  | 10 ++++++++--
 sound/pci/intel8x0m.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index a51032b3ac4d..ae285c0a629c 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -3109,8 +3109,8 @@ static int check_default_spdif_aclink(struct pci_dev *pci)
 	return 0;
 }
 
-static int snd_intel8x0_probe(struct pci_dev *pci,
-			      const struct pci_device_id *pci_id)
+static int __snd_intel8x0_probe(struct pci_dev *pci,
+				const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct intel8x0 *chip;
@@ -3189,6 +3189,12 @@ static int snd_intel8x0_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_intel8x0_probe(struct pci_dev *pci,
+			      const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_intel8x0_probe(pci, pci_id));
+}
+
 static struct pci_driver intel8x0_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_intel8x0_ids,
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 7de3cb2f17b5..2845cc006d0c 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1178,8 +1178,8 @@ static struct shortname_table {
 	{ 0 },
 };
 
-static int snd_intel8x0m_probe(struct pci_dev *pci,
-			       const struct pci_device_id *pci_id)
+static int __snd_intel8x0m_probe(struct pci_dev *pci,
+				 const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct intel8x0m *chip;
@@ -1225,6 +1225,12 @@ static int snd_intel8x0m_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_intel8x0m_probe(struct pci_dev *pci,
+			       const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_intel8x0m_probe(pci, pci_id));
+}
+
 static struct pci_driver intel8x0m_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_intel8x0m_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 19/39] ALSA: korg1212: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (17 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 18/39] ALSA: intel8x0: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 20/39] ALSA: maestro3: " Takashi Iwai
                   ` (19 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 5c9e240ff6a9..33b4f95d65b3 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2355,7 +2355,7 @@ snd_korg1212_probe(struct pci_dev *pci,
 
 	err = snd_korg1212_create(card, pci);
 	if (err < 0)
-		return err;
+		goto error;
 
 	strcpy(card->driver, "korg1212");
 	strcpy(card->shortname, "korg1212");
@@ -2366,10 +2366,14 @@ snd_korg1212_probe(struct pci_dev *pci,
 
 	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;
 }
 
 static struct pci_driver korg1212_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 20/39] ALSA: maestro3: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (18 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 19/39] ALSA: korg1212: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 21/39] ALSA: riptide: " Takashi Iwai
                   ` (18 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 5c0939253c3c ("ALSA: maestro3: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/maestro3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 056838ead21d..261850775c80 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2637,7 +2637,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
 /*
  */
 static int
-snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+__snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2702,6 +2702,12 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 	return 0;
 }
 
+static int
+snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_m3_probe(pci, pci_id));
+}
+
 static struct pci_driver m3_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_m3_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 21/39] ALSA: riptide: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (19 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 20/39] ALSA: maestro3: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 22/39] ALSA: rme32: " Takashi Iwai
                   ` (17 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 546c201a891e ("ALSA: riptide: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/riptide/riptide.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 5a987c683c41..b37c877c2c16 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -2023,7 +2023,7 @@ static void snd_riptide_joystick_remove(struct pci_dev *pci)
 #endif
 
 static int
-snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+__snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -2124,6 +2124,12 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 	return 0;
 }
 
+static int
+snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_card_riptide_probe(pci, pci_id));
+}
+
 static struct pci_driver driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_riptide_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 22/39] ALSA: rme32: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (20 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 21/39] ALSA: riptide: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 23/39] ALSA: rme96: " Takashi Iwai
                   ` (16 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 102e6156ded2 ("ALSA: rme32: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/rme32.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 5b6bd9f0b2f7..9c0ac025e143 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1875,7 +1875,7 @@ static void snd_rme32_card_free(struct snd_card *card)
 }
 
 static int
-snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+__snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct rme32 *rme32;
@@ -1927,6 +1927,12 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 	return 0;
 }
 
+static int
+snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_rme32_probe(pci, pci_id));
+}
+
 static struct pci_driver rme32_driver = {
 	.name =		KBUILD_MODNAME,
 	.id_table =	snd_rme32_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 23/39] ALSA: rme96: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (21 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 22/39] ALSA: rme32: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 24/39] ALSA: sonicvibes: " Takashi Iwai
                   ` (15 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: df06df7cc997 ("ALSA: rme96: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/rme96.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 8fc811504920..bccb7e0d3d11 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -2430,8 +2430,8 @@ static void snd_rme96_card_free(struct snd_card *card)
 }
 
 static int
-snd_rme96_probe(struct pci_dev *pci,
-		const struct pci_device_id *pci_id)
+__snd_rme96_probe(struct pci_dev *pci,
+		  const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct rme96 *rme96;
@@ -2498,6 +2498,12 @@ snd_rme96_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_rme96_probe(struct pci_dev *pci,
+			   const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_rme96_probe(pci, pci_id));
+}
+
 static struct pci_driver rme96_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_rme96_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 24/39] ALSA: sonicvibes: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (22 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 23/39] ALSA: rme96: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 25/39] ALSA: via82xx: " Takashi Iwai
                   ` (14 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 2ca6cbde6ad7 ("ALSA: sonicvibes: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/sonicvibes.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index c8c49881008f..f91cbf6eeca0 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1387,8 +1387,8 @@ static int snd_sonicvibes_midi(struct sonicvibes *sonic,
 	return 0;
 }
 
-static int snd_sonic_probe(struct pci_dev *pci,
-			   const struct pci_device_id *pci_id)
+static int __snd_sonic_probe(struct pci_dev *pci,
+			     const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -1459,6 +1459,12 @@ static int snd_sonic_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_sonic_probe(struct pci_dev *pci,
+			   const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_sonic_probe(pci, pci_id));
+}
+
 static struct pci_driver sonicvibes_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_sonic_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 25/39] ALSA: via82xx: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (23 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 24/39] ALSA: sonicvibes: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 26/39] ALSA: intel_hdmi: " Takashi Iwai
                   ` (13 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: afaf99751d0c ("ALSA: via82xx: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/via82xx.c       | 10 ++++++++--
 sound/pci/via82xx_modem.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 65514f7e42d7..361b83fd721e 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -2458,8 +2458,8 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
 	return VIA_DXS_48K;
 };
 
-static int snd_via82xx_probe(struct pci_dev *pci,
-			     const struct pci_device_id *pci_id)
+static int __snd_via82xx_probe(struct pci_dev *pci,
+			       const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct via82xx *chip;
@@ -2569,6 +2569,12 @@ static int snd_via82xx_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_via82xx_probe(struct pci_dev *pci,
+			     const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id));
+}
+
 static struct pci_driver via82xx_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_via82xx_ids,
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 234f7fbed236..ca7f024bf8ec 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1103,8 +1103,8 @@ static int snd_via82xx_create(struct snd_card *card,
 }
 
 
-static int snd_via82xx_probe(struct pci_dev *pci,
-			     const struct pci_device_id *pci_id)
+static int __snd_via82xx_probe(struct pci_dev *pci,
+			       const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct via82xx_modem *chip;
@@ -1157,6 +1157,12 @@ static int snd_via82xx_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_via82xx_probe(struct pci_dev *pci,
+			     const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id));
+}
+
 static struct pci_driver via82xx_modem_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_via82xx_modem_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 26/39] ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (24 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 25/39] ALSA: via82xx: " Takashi Iwai
@ 2022-04-12 10:26 ` 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
                   ` (12 subsequent siblings)
  38 siblings, 1 reply; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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(-)

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)
 };
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 27/39] ALSA: sis7019: Fix the missing error handling
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (25 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 26/39] ALSA: intel_hdmi: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 28/39] ALSA: bt87x: Fix the missing snd_card_free() call at probe error Takashi Iwai
                   ` (11 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

The previous cleanup with devres forgot to replace the snd_card_free()
call with the devm version.  Moreover, it still needs the manual call
of snd_card_free() at the probe error path, otherwise the reverse
order of the releases may happen.  This patch addresses those issues.

Fixes: 499ddc16394c ("ALSA: sis7019: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/sis7019.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index 0b722b0e0604..fabe393607f8 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1331,8 +1331,8 @@ static int sis_chip_create(struct snd_card *card,
 	return 0;
 }
 
-static int snd_sis7019_probe(struct pci_dev *pci,
-			     const struct pci_device_id *pci_id)
+static int __snd_sis7019_probe(struct pci_dev *pci,
+			       const struct pci_device_id *pci_id)
 {
 	struct snd_card *card;
 	struct sis7019 *sis;
@@ -1352,8 +1352,8 @@ static int snd_sis7019_probe(struct pci_dev *pci,
 	if (!codecs)
 		codecs = SIS_PRIMARY_CODEC_PRESENT;
 
-	rc = snd_card_new(&pci->dev, index, id, THIS_MODULE,
-			  sizeof(*sis), &card);
+	rc = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE,
+			       sizeof(*sis), &card);
 	if (rc < 0)
 		return rc;
 
@@ -1386,6 +1386,12 @@ static int snd_sis7019_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_sis7019_probe(struct pci_dev *pci,
+			     const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_sis7019_probe(pci, pci_id));
+}
+
 static struct pci_driver sis7019_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = snd_sis7019_ids,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 28/39] ALSA: bt87x: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (26 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 27/39] ALSA: sis7019: Fix the missing error handling Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 29/39] ALSA: lola: " Takashi Iwai
                   ` (10 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 9e80ed64a006 ("ALSA: bt87x: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/bt87x.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index d23f93163841..621985bfee5d 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -805,8 +805,8 @@ static int snd_bt87x_detect_card(struct pci_dev *pci)
 	return SND_BT87X_BOARD_UNKNOWN;
 }
 
-static int snd_bt87x_probe(struct pci_dev *pci,
-			   const struct pci_device_id *pci_id)
+static int __snd_bt87x_probe(struct pci_dev *pci,
+			     const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -889,6 +889,12 @@ static int snd_bt87x_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int snd_bt87x_probe(struct pci_dev *pci,
+			   const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __snd_bt87x_probe(pci, pci_id));
+}
+
 /* default entries for all Bt87x cards - it's not exported */
 /* driver_data is set to 0 to call detection */
 static const struct pci_device_id snd_bt87x_default_ids[] = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 29/39] ALSA: lola: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (27 preceding siblings ...)
  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 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 30/39] ALSA: als300: " Takashi Iwai
                   ` (9 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 098fe3d6e775 ("ALSA: lola: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/lola/lola.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 5269a1d396a5..1aa30e90b86a 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -637,8 +637,8 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci, int dev)
 	return 0;
 }
 
-static int lola_probe(struct pci_dev *pci,
-		      const struct pci_device_id *pci_id)
+static int __lola_probe(struct pci_dev *pci,
+			const struct pci_device_id *pci_id)
 {
 	static int dev;
 	struct snd_card *card;
@@ -687,6 +687,12 @@ static int lola_probe(struct pci_dev *pci,
 	return 0;
 }
 
+static int lola_probe(struct pci_dev *pci,
+		      const struct pci_device_id *pci_id)
+{
+	return snd_card_free_on_error(&pci->dev, __lola_probe(pci, pci_id));
+}
+
 /* PCI IDs */
 static const struct pci_device_id lola_ids[] = {
 	{ PCI_VDEVICE(DIGIGRAM, 0x0001) },
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 30/39] ALSA: als300: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (28 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 29/39] ALSA: lola: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 31/39] ALSA: aw2: " Takashi Iwai
                   ` (8 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index b86565dcdbe4..c70aff060120 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -708,7 +708,7 @@ static int snd_als300_probe(struct pci_dev *pci,
 
 	err = snd_als300_create(card, pci, chip_type);
 	if (err < 0)
-		return err;
+		goto error;
 
 	strcpy(card->driver, "ALS300");
 	if (chip->chip_type == DEVICE_ALS300_PLUS)
@@ -723,11 +723,15 @@ static int snd_als300_probe(struct pci_dev *pci,
 
 	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;
 }
 
 static struct pci_driver als300_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 31/39] ALSA: aw2: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (29 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 30/39] ALSA: als300: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 32/39] ALSA: cmipci: " Takashi Iwai
                   ` (7 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 33631012cd06 ("ALSA: aw2: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/aw2/aw2-alsa.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index d56f126d6fdd..29a4bcdec237 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -275,7 +275,7 @@ static int snd_aw2_probe(struct pci_dev *pci,
 	/* (3) Create main component */
 	err = snd_aw2_create(card, pci);
 	if (err < 0)
-		return err;
+		goto error;
 
 	/* initialize mutex */
 	mutex_init(&chip->mtx);
@@ -294,13 +294,17 @@ static int snd_aw2_probe(struct pci_dev *pci,
 	/* (6) Register card instance */
 	err = snd_card_register(card);
 	if (err < 0)
-		return err;
+		goto error;
 
 	/* (7) Set PCI driver data */
 	pci_set_drvdata(pci, card);
 
 	dev++;
 	return 0;
+
+ error:
+	snd_card_free(card);
+	return err;
 }
 
 /* open callback */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 32/39] ALSA: cmipci: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (30 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 31/39] ALSA: aw2: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 33/39] ALSA: lx6464es: " Takashi Iwai
                   ` (6 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 33/39] ALSA: lx6464es: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (31 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 32/39] ALSA: cmipci: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 34/39] ALSA: oxygen: " Takashi Iwai
                   ` (5 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 168a1084f730..bd9b6148dd6f 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1019,7 +1019,7 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
 	err = snd_lx6464es_create(card, pci);
 	if (err < 0) {
 		dev_err(card->dev, "error during snd_lx6464es_create\n");
-		return err;
+		goto error;
 	}
 
 	strcpy(card->driver, "LX6464ES");
@@ -1036,12 +1036,16 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
 
 	err = snd_card_register(card);
 	if (err < 0)
-		return err;
+		goto error;
 
 	dev_dbg(chip->card->dev, "initialization successful\n");
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+ error:
+	snd_card_free(card);
+	return err;
 }
 
 static struct pci_driver lx6464es_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 34/39] ALSA: oxygen: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (32 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 33/39] ALSA: lx6464es: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 35/39] ALSA: hdsp: " Takashi Iwai
                   ` (4 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 596ae97ab0ce ("ALSA: oxygen: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/oxygen/oxygen_lib.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index 4fb3f2484fdb..92ffe9dc20c5 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -576,7 +576,7 @@ static void oxygen_card_free(struct snd_card *card)
 	mutex_destroy(&chip->mutex);
 }
 
-int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
+static int __oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
 		     struct module *owner,
 		     const struct pci_device_id *ids,
 		     int (*get_model)(struct oxygen *chip,
@@ -701,6 +701,16 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
 	pci_set_drvdata(pci, card);
 	return 0;
 }
+
+int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
+		     struct module *owner,
+		     const struct pci_device_id *ids,
+		     int (*get_model)(struct oxygen *chip,
+				      const struct pci_device_id *id))
+{
+	return snd_card_free_on_error(&pci->dev,
+				      __oxygen_pci_probe(pci, index, id, owner, ids, get_model));
+}
 EXPORT_SYMBOL(oxygen_pci_probe);
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 35/39] ALSA: hdsp: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (33 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 34/39] ALSA: oxygen: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 36/39] ALSA: hdspm: " Takashi Iwai
                   ` (3 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 96c12dfb24cf..3db641318d3a 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -5444,17 +5444,21 @@ static int snd_hdsp_probe(struct pci_dev *pci,
 	hdsp->pci = pci;
 	err = snd_hdsp_create(card, hdsp);
 	if (err)
-		return err;
+		goto error;
 
 	strcpy(card->shortname, "Hammerfall DSP");
 	sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
 		hdsp->port, hdsp->irq);
 	err = snd_card_register(card);
 	if (err)
-		return err;
+		goto error;
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+ error:
+	snd_card_free(card);
+	return err;
 }
 
 static struct pci_driver hdsp_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 36/39] ALSA: hdspm: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (34 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 35/39] ALSA: hdsp: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 37/39] ALSA: rme9652: " Takashi Iwai
                   ` (2 subsequent siblings)
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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: 0195ca5fd1f4 ("ALSA: hdspm: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/rme9652/hdspm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index ff06ee82607c..fa1812e7a49d 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -6895,7 +6895,7 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 
 	err = snd_hdspm_create(card, hdspm);
 	if (err < 0)
-		return err;
+		goto error;
 
 	if (hdspm->io_type != MADIface) {
 		snprintf(card->shortname, sizeof(card->shortname), "%s_%x",
@@ -6914,12 +6914,16 @@ static int snd_hdspm_probe(struct pci_dev *pci,
 
 	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;
 }
 
 static struct pci_driver hdspm_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 37/39] ALSA: rme9652: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (35 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 36/39] ALSA: hdspm: " Takashi Iwai
@ 2022-04-12 10:26 ` 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
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

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

diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 7755e19aa776..1d614fe89a6a 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -2572,7 +2572,7 @@ static int snd_rme9652_probe(struct pci_dev *pci,
 	rme9652->pci = pci;
 	err = snd_rme9652_create(card, rme9652, precise_ptr[dev]);
 	if (err)
-		return err;
+		goto error;
 
 	strcpy(card->shortname, rme9652->card_name);
 
@@ -2580,10 +2580,14 @@ static int snd_rme9652_probe(struct pci_dev *pci,
 		card->shortname, rme9652->port, rme9652->irq);
 	err = snd_card_register(card);
 	if (err)
-		return err;
+		goto error;
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+ error:
+	snd_card_free(card);
+	return err;
 }
 
 static struct pci_driver rme9652_driver = {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 38/39] ALSA: mtpav: Don't call card private_free at probe error path
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (36 preceding siblings ...)
  2022-04-12 10:26 ` [PATCH 37/39] ALSA: rme9652: " Takashi Iwai
@ 2022-04-12 10:26 ` Takashi Iwai
  2022-04-12 10:26 ` [PATCH 39/39] ALSA: nm256: " Takashi Iwai
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

The card destructor of nm256 driver does merely stopping the running
timer, and it's superfluous for the probe error handling.  Moreover,
calling this via the previous devres change would lead to another
problem due to the reverse call order.

This patch moves the setup of the private_free callback after the card
registration, so that it can be used only after fully set up.

Fixes: aa92050f10f0 ("ALSA: mtpav: Allocate resources with device-managed APIs")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/drivers/mtpav.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c
index 11235baaf6fa..f212f233ea61 100644
--- a/sound/drivers/mtpav.c
+++ b/sound/drivers/mtpav.c
@@ -693,8 +693,6 @@ static int snd_mtpav_probe(struct platform_device *dev)
 	mtp_card->outmidihwport = 0xffffffff;
 	timer_setup(&mtp_card->timer, snd_mtpav_output_timer, 0);
 
-	card->private_free = snd_mtpav_free;
-
 	err = snd_mtpav_get_RAWMIDI(mtp_card);
 	if (err < 0)
 		return err;
@@ -716,6 +714,8 @@ static int snd_mtpav_probe(struct platform_device *dev)
 	if (err < 0)
 		return err;
 
+	card->private_free = snd_mtpav_free;
+
 	platform_set_drvdata(dev, card);
 	printk(KERN_INFO "Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", irq, port);
 	return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH 39/39] ALSA: nm256: Don't call card private_free at probe error path
  2022-04-12 10:25 [PATCH 00/39] ALSA: Fix error handling order at probe error Takashi Iwai
                   ` (37 preceding siblings ...)
  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 ` Takashi Iwai
  38 siblings, 0 replies; 41+ messages in thread
From: Takashi Iwai @ 2022-04-12 10:26 UTC (permalink / raw)
  To: alsa-devel

The card destructor of nm256 driver does merely stopping the running
streams, and it's superfluous for the probe error handling.  Moreover,
calling this via the previous devres change would lead to another
problem due to the reverse call order.

This patch moves the setup of the private_free callback after the card
registration, so that it can be used only after fully set up.

Fixes: c19935f04784 ("ALSA: nm256: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/nm256/nm256.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index c9c178504959..f99a1e96e923 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1573,7 +1573,6 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci)
 	chip->coeffs_current = 0;
 
 	snd_nm256_init_chip(chip);
-	card->private_free = snd_nm256_free;
 
 	// pci_set_master(pci); /* needed? */
 	return 0;
@@ -1680,6 +1679,7 @@ static int snd_nm256_probe(struct pci_dev *pci,
 	err = snd_card_register(card);
 	if (err < 0)
 		return err;
+	card->private_free = snd_nm256_free;
 
 	pci_set_drvdata(pci, card);
 	return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH 26/39] ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error
  2022-04-12 10:26 ` [PATCH 26/39] ALSA: intel_hdmi: " Takashi Iwai
@ 2022-04-12 17:14   ` kernel test robot
  0 siblings, 0 replies; 41+ messages in thread
From: kernel test robot @ 2022-04-12 17:14 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel; +Cc: kbuild-all

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	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2022-04-12 17:16 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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.