Skip to contentSkip to conversation

ALSA: Fix error handling order at probe error

PATCH New Takashi Iwai 2 participants 41 messages Apr 12, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ALSA: Fix error handling order at probe error

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(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/39 ALSA: galaxy: Fix the missing snd_card_free() call at probe error

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")
---
 sound/isa/galaxy/galaxy.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/isa/galaxy/galaxy.c +6 -1
index ea001c80149d..3164eb8510fa 100644
@@ -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,
Signature · 1 line
2.31.1
#2 lore raw

PATCH 2/39 ALSA: sc6000: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/isa/sc6000.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/isa/sc6000.c +6 -1
index 26ab7ff80768..60398fced046 100644
@@ -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,
Signature · 1 line
2.31.1
#3 lore raw

PATCH 3/39 ALSA: ad1889: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/ad1889.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ad1889.c +8 -2
index bba4dae8dcc7..50e30704bf6f 100644
@@ -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, },
Signature · 1 line
2.31.1
#4 lore raw

PATCH 4/39 ALSA: ali5451: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/ali5451/ali5451.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ali5451/ali5451.c +8 -2
index 92eb59db106d..2378a39abaeb 100644
@@ -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,
Signature · 1 line
2.31.1
#5 lore raw

PATCH 5/39 ALSA: als4000: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/als4000.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/als4000.c +8 -2
index 535eccd124be..f33aeb692a11 100644
@@ -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)
 {
Signature · 1 line
2.31.1
#6 lore raw

PATCH 6/39 ALSA: atiixp: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/atiixp.c       | 10 ++++++++--
 sound/pci/atiixp_modem.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
sound/pci/atiixp.c +8 -2
index b8e035d5930d..43d01f1847ed 100644
@@ -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,
sound/pci/atiixp_modem.c +8 -2
index 178dce8ef1e9..8864c4c3c7e1 100644
@@ -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,
Signature · 1 line
2.31.1
#7 lore raw

PATCH 7/39 ALSA: au88x0: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/au88x0/au88x0.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/au88x0/au88x0.c +7 -1
index 342ef2a6655e..eb234153691b 100644
@@ -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,
Signature · 1 line
2.31.1
#8 lore raw

PATCH 8/39 ALSA: azt3328: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/azt3328.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/azt3328.c +7 -1
index 089050470ff2..7f329dfc5404 100644
@@ -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,
Signature · 1 line
2.31.1
#9 lore raw

PATCH 9/39 ALSA: ca0106: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/ca0106/ca0106_main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ca0106/ca0106_main.c +8 -2
index 8577f9fa5ea6..cf1bac7a435f 100644
@@ -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)
 {
Signature · 1 line
2.31.1
#10 lore raw

PATCH 10/39 ALSA: cs4281: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/cs4281.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/cs4281.c +8 -2
index e7367402b84a..0c9cadf7b3b8 100644
@@ -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
  */
Signature · 1 line
2.31.1
#11 lore raw

PATCH 11/39 ALSA: cs5535audio: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/cs5535audio/cs5535audio.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/cs5535audio/cs5535audio.c +8 -2
index 499fa0148f9a..440b8f9b40c9 100644
@@ -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,
Signature · 1 line
2.31.1
#12 lore raw

PATCH 12/39 ALSA: emu10k1x: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/emu10k1/emu10k1x.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/emu10k1/emu10k1x.c +8 -2
index c49c44dc1082..89043392f3ec 100644
@@ -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) */
Signature · 1 line
2.31.1
#13 lore raw

PATCH 13/39 ALSA: ens137x: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/ens1370.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ens1370.c +8 -2
index 2651f0c64c06..94efe347a97a 100644
@@ -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,
Signature · 1 line
2.31.1
#14 lore raw

PATCH 14/39 ALSA: es1938: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/es1938.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/es1938.c +8 -2
index 00b976f42a3d..e34ec6f89e7e 100644
@@ -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,
Signature · 1 line
2.31.1
#15 lore raw

PATCH 15/39 ALSA: es1968: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/es1968.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/es1968.c +8 -2
index 6a8a02a9ecf4..4a7e20bb11bc 100644
@@ -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,
Signature · 1 line
2.31.1
#16 lore raw

PATCH 16/39 ALSA: fm801: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/fm801.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/fm801.c +8 -2
index 9c22ff19e56d..62b3cb126c6d 100644
@@ -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,
Signature · 1 line
2.31.1
#17 lore raw

PATCH 17/39 ALSA: ice1724: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/ice1712/ice1724.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ice1712/ice1724.c +8 -2
index f6275868877a..6fab2ad85bbe 100644
@@ -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)
 {
Signature · 1 line
2.31.1
#18 lore raw

PATCH 18/39 ALSA: intel8x0: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/intel8x0.c  | 10 ++++++++--
 sound/pci/intel8x0m.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
sound/pci/intel8x0.c +8 -2
index a51032b3ac4d..ae285c0a629c 100644
@@ -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,
sound/pci/intel8x0m.c +8 -2
index 7de3cb2f17b5..2845cc006d0c 100644
@@ -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,
Signature · 1 line
2.31.1
#19 lore raw

PATCH 19/39 ALSA: korg1212: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/korg1212/korg1212.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/korg1212/korg1212.c +6 -2
index 5c9e240ff6a9..33b4f95d65b3 100644
@@ -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 = {
Signature · 1 line
2.31.1
#20 lore raw

PATCH 20/39 ALSA: maestro3: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/maestro3.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/maestro3.c +7 -1
index 056838ead21d..261850775c80 100644
@@ -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,
Signature · 1 line
2.31.1
#21 lore raw

PATCH 21/39 ALSA: riptide: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/riptide/riptide.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/riptide/riptide.c +7 -1
index 5a987c683c41..b37c877c2c16 100644
@@ -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,
Signature · 1 line
2.31.1
#22 lore raw

PATCH 22/39 ALSA: rme32: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/rme32.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pci/rme32.c +7 -1
index 5b6bd9f0b2f7..9c0ac025e143 100644
@@ -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,
Signature · 1 line
2.31.1
#23 lore raw

PATCH 23/39 ALSA: rme96: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/rme96.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/rme96.c +8 -2
index 8fc811504920..bccb7e0d3d11 100644
@@ -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,
Signature · 1 line
2.31.1
#24 lore raw

PATCH 24/39 ALSA: sonicvibes: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/sonicvibes.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/sonicvibes.c +8 -2
index c8c49881008f..f91cbf6eeca0 100644
@@ -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,
Signature · 1 line
2.31.1
#25 lore raw

PATCH 25/39 ALSA: via82xx: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/via82xx.c       | 10 ++++++++--
 sound/pci/via82xx_modem.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
sound/pci/via82xx.c +8 -2
index 65514f7e42d7..361b83fd721e 100644
@@ -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,
sound/pci/via82xx_modem.c +8 -2
index 234f7fbed236..ca7f024bf8ec 100644
@@ -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,
Signature · 1 line
2.31.1
#26 lore raw

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

In reply to Takashi Iwai

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")
---
 sound/x86/intel_hdmi_audio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
sound/x86/intel_hdmi_audio.c +6 -1
index b00634663346..0d828e35b401 100644
@@ -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)
 };
Signature · 1 line
2.31.1
#27 lore raw

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

I love your patch! Yet something to improve:

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/[email protected]/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

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

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#28 lore raw

PATCH 27/39 ALSA: sis7019: Fix the missing error handling

In reply to Takashi Iwai

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")
---
 sound/pci/sis7019.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
sound/pci/sis7019.c +10 -4
index 0b722b0e0604..fabe393607f8 100644
@@ -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,
Signature · 1 line
2.31.1
#29 lore raw

PATCH 28/39 ALSA: bt87x: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/bt87x.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/bt87x.c +8 -2
index d23f93163841..621985bfee5d 100644
@@ -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[] = {
Signature · 1 line
2.31.1
#30 lore raw

PATCH 29/39 ALSA: lola: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/lola/lola.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/lola/lola.c +8 -2
index 5269a1d396a5..1aa30e90b86a 100644
@@ -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) },
Signature · 1 line
2.31.1
#31 lore raw

PATCH 30/39 ALSA: als300: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/als300.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/als300.c +6 -2
index b86565dcdbe4..c70aff060120 100644
@@ -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 = {
Signature · 1 line
2.31.1
#32 lore raw

PATCH 31/39 ALSA: aw2: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/aw2/aw2-alsa.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/aw2/aw2-alsa.c +6 -2
index d56f126d6fdd..29a4bcdec237 100644
@@ -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 */
Signature · 1 line
2.31.1
#33 lore raw

PATCH 32/39 ALSA: cmipci: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/cmipci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/cmipci.c +6 -2
index dab801d9d3b4..727db6d43391 100644
@@ -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
Signature · 1 line
2.31.1
#34 lore raw

PATCH 33/39 ALSA: lx6464es: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/lx6464es/lx6464es.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/lx6464es/lx6464es.c +6 -2
index 168a1084f730..bd9b6148dd6f 100644
@@ -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 = {
Signature · 1 line
2.31.1
#35 lore raw

PATCH 34/39 ALSA: oxygen: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/oxygen/oxygen_lib.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
sound/pci/oxygen/oxygen_lib.c +11 -1
index 4fb3f2484fdb..92ffe9dc20c5 100644
@@ -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
Signature · 1 line
2.31.1
#36 lore raw

PATCH 35/39 ALSA: hdsp: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/rme9652/hdsp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/rme9652/hdsp.c +6 -2
index 96c12dfb24cf..3db641318d3a 100644
@@ -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 = {
Signature · 1 line
2.31.1
#37 lore raw

PATCH 36/39 ALSA: hdspm: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/rme9652/hdspm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/rme9652/hdspm.c +6 -2
index ff06ee82607c..fa1812e7a49d 100644
@@ -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 = {
Signature · 1 line
2.31.1
#38 lore raw

PATCH 37/39 ALSA: rme9652: Fix the missing snd_card_free() call at probe error

In reply to Takashi Iwai

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")
---
 sound/pci/rme9652/rme9652.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
sound/pci/rme9652/rme9652.c +6 -2
index 7755e19aa776..1d614fe89a6a 100644
@@ -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 = {
Signature · 1 line
2.31.1
#39 lore raw

PATCH 38/39 ALSA: mtpav: Don't call card private_free at probe error path

In reply to Takashi Iwai

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")
---
 sound/drivers/mtpav.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/drivers/mtpav.c +2 -2
index 11235baaf6fa..f212f233ea61 100644
@@ -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;
Signature · 1 line
2.31.1
#40 lore raw

PATCH 39/39 ALSA: nm256: Don't call card private_free at probe error path

In reply to Takashi Iwai

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")
---
 sound/pci/nm256/nm256.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/nm256/nm256.c +1 -1
index c9c178504959..f99a1e96e923 100644
@@ -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;
Signature · 1 line
2.31.1