From: Greg Kroah-Hartman Date: Fri, 15 Apr 2022 10:56:18 +0000 (+0200) Subject: 5.17-stable patches X-Git-Tag: v4.19.238~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ecc6589f9b8c36056bff960488e9b6f6ea6f070;p=thirdparty%2Fkernel%2Fstable-queue.git 5.17-stable patches added patches: alsa-ali5451-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-als300-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-als4000-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-atiixp-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-au88x0-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-aw2-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-azt3328-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-bt87x-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-ca0106-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-cmipci-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-cs4281-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-cs5535audio-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-echoaudio-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-emu10k1x-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-ens137x-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-es1938-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-es1968-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-fm801-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-galaxy-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-hdsp-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-hdspm-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-ice1724-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-intel8x0-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-intel_hdmi-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-korg1212-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-lola-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-lx6464es-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-maestro3-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-memalloc-add-fallback-sg-buffer-allocations-for-x86.patch alsa-oxygen-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-riptide-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-rme32-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-rme96-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-rme9652-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-sc6000-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-sonicvibes-fix-the-missing-snd_card_free-call-at-probe-error.patch alsa-usb-audio-cap-upper-limits-of-buffer-period-bytes-for-implicit-fb.patch alsa-via82xx-fix-the-missing-snd_card_free-call-at-probe-error.patch --- diff --git a/queue-5.17/alsa-ali5451-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-ali5451-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..e8d1cb6f001 --- /dev/null +++ b/queue-5.17/alsa-ali5451-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From 19401a9441236cfbbbeb1bef4ef4c8668db45dfc Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:01 +0200 +Subject: ALSA: ali5451: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 19401a9441236cfbbbeb1bef4ef4c8668db45dfc upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-5-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/ali5451/ali5451.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/ali5451/ali5451.c ++++ b/sound/pci/ali5451/ali5451.c +@@ -2124,8 +2124,8 @@ static int snd_ali_create(struct snd_car + 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 + 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, diff --git a/queue-5.17/alsa-als300-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-als300-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..de2683ad577 --- /dev/null +++ b/queue-5.17/alsa-als300-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,55 @@ +From ab8bce9da6102c575c473c053672547589bc4c59 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:27 +0200 +Subject: ALSA: als300: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit ab8bce9da6102c575c473c053672547589bc4c59 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-31-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/als300.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/als300.c ++++ b/sound/pci/als300.c +@@ -708,7 +708,7 @@ static int snd_als300_probe(struct pci_d + + 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_d + + 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 = { diff --git a/queue-5.17/alsa-als4000-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-als4000-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..697d72e7cb6 --- /dev/null +++ b/queue-5.17/alsa-als4000-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From d616a0246da88d811f9f4c3aa83003c05efd3af0 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:02 +0200 +Subject: ALSA: als4000: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit d616a0246da88d811f9f4c3aa83003c05efd3af0 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-6-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/als4000.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/als4000.c ++++ b/sound/pci/als4000.c +@@ -806,8 +806,8 @@ static void snd_card_als4000_free( struc + 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 + 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) + { diff --git a/queue-5.17/alsa-atiixp-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-atiixp-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..32a13fd00c7 --- /dev/null +++ b/queue-5.17/alsa-atiixp-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,80 @@ +From 48e8adde8d1c586c799dab123fc1ebc8b8db620f Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:03 +0200 +Subject: ALSA: atiixp: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 48e8adde8d1c586c799dab123fc1ebc8b8db620f upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-7-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/atiixp.c | 10 ++++++++-- + sound/pci/atiixp_modem.c | 10 ++++++++-- + 2 files changed, 16 insertions(+), 4 deletions(-) + +--- a/sound/pci/atiixp.c ++++ b/sound/pci/atiixp.c +@@ -1572,8 +1572,8 @@ static int snd_atiixp_init(struct snd_ca + } + + +-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_d + 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, +--- a/sound/pci/atiixp_modem.c ++++ b/sound/pci/atiixp_modem.c +@@ -1201,8 +1201,8 @@ static int snd_atiixp_init(struct snd_ca + } + + +-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_d + 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, diff --git a/queue-5.17/alsa-au88x0-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-au88x0-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..3bd532f552b --- /dev/null +++ b/queue-5.17/alsa-au88x0-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From b093de145bc8769c6e9207947afad9efe102f4f6 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:04 +0200 +Subject: ALSA: au88x0: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit b093de145bc8769c6e9207947afad9efe102f4f6 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-8-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/au88x0/au88x0.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/sound/pci/au88x0/au88x0.c ++++ b/sound/pci/au88x0/au88x0.c +@@ -193,7 +193,7 @@ snd_vortex_create(struct snd_card *card, + + // 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, co + 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, diff --git a/queue-5.17/alsa-aw2-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-aw2-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..151636b3fc5 --- /dev/null +++ b/queue-5.17/alsa-aw2-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,57 @@ +From bf4067e8a19eae67c45659a956c361d59251ba57 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:28 +0200 +Subject: ALSA: aw2: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit bf4067e8a19eae67c45659a956c361d59251ba57 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-32-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/aw2/aw2-alsa.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- 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 + /* (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 + /* (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 */ diff --git a/queue-5.17/alsa-azt3328-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-azt3328-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..4db1ed24191 --- /dev/null +++ b/queue-5.17/alsa-azt3328-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From 49fe36e1c02cb06f66689c888e4e767c31cd259d Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:05 +0200 +Subject: ALSA: azt3328: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 49fe36e1c02cb06f66689c888e4e767c31cd259d upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-9-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/azt3328.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- 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, c + 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, diff --git a/queue-5.17/alsa-bt87x-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-bt87x-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..b07cc6cfed2 --- /dev/null +++ b/queue-5.17/alsa-bt87x-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From f0438155273f057fec9818bc9d1b782ba35cf6a1 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:25 +0200 +Subject: ALSA: bt87x: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit f0438155273f057fec9818bc9d1b782ba35cf6a1 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-29-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/bt87x.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/bt87x.c ++++ b/sound/pci/bt87x.c +@@ -805,8 +805,8 @@ static int snd_bt87x_detect_card(struct + 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_de + 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[] = { diff --git a/queue-5.17/alsa-ca0106-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-ca0106-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..e047e467cf5 --- /dev/null +++ b/queue-5.17/alsa-ca0106-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From c79442cc5a38e46597bc647128c8f1de62d80020 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:06 +0200 +Subject: ALSA: ca0106: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit c79442cc5a38e46597bc647128c8f1de62d80020 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-10-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/ca0106/ca0106_main.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- 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_ca + } + + +-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_d + 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) + { diff --git a/queue-5.17/alsa-cmipci-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-cmipci-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..8c43ecd7025 --- /dev/null +++ b/queue-5.17/alsa-cmipci-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From a59396b1c11823c69c31621198c04def17f3a869 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:29 +0200 +Subject: ALSA: cmipci: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit a59396b1c11823c69c31621198c04def17f3a869 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-33-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/cmipci.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/cmipci.c ++++ b/sound/pci/cmipci.c +@@ -3247,15 +3247,19 @@ static int snd_cmipci_probe(struct pci_d + + 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 diff --git a/queue-5.17/alsa-cs4281-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-cs4281-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..719605db9b5 --- /dev/null +++ b/queue-5.17/alsa-cs4281-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From 9bf5ed9a4e623583f15202d99f4521bc39050f61 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:07 +0200 +Subject: ALSA: cs4281: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 9bf5ed9a4e623583f15202d99f4521bc39050f61 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-11-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/cs4281.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/cs4281.c ++++ b/sound/pci/cs4281.c +@@ -1827,8 +1827,8 @@ static void snd_cs4281_opl3_command(stru + 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_d + 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 + */ diff --git a/queue-5.17/alsa-cs5535audio-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-cs5535audio-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..232f55111bf --- /dev/null +++ b/queue-5.17/alsa-cs5535audio-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,50 @@ +From 2a56314798e0227cf51e3d1d184a419dc07bc173 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:08 +0200 +Subject: ALSA: cs5535audio: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 2a56314798e0227cf51e3d1d184a419dc07bc173 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-12-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/cs5535audio/cs5535audio.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/cs5535audio/cs5535audio.c ++++ b/sound/pci/cs5535audio/cs5535audio.c +@@ -281,8 +281,8 @@ static int snd_cs5535audio_create(struct + 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 + 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, diff --git a/queue-5.17/alsa-echoaudio-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-echoaudio-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..96be950b475 --- /dev/null +++ b/queue-5.17/alsa-echoaudio-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,54 @@ +From 313c7e57035125cb7533b53ddd0bc7aa562b433c Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 11:31:41 +0200 +Subject: ALSA: echoaudio: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 313c7e57035125cb7533b53ddd0bc7aa562b433c upstream. + +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: 9c211bf392bb ("ALSA: echoaudio: Allocate resources with device-managed APIs") +Reported-and-tested-by: Zheyu Ma +Cc: +Link: https://lore.kernel.org/r/CAMhUBjm2AdyEZ_-EgexdNDN7SvY4f89=4=FwAL+c0Mg0O+X50A@mail.gmail.com +Link: https://lore.kernel.org/r/20220412093141.8008-3-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/echoaudio/echoaudio.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +--- a/sound/pci/echoaudio/echoaudio.c ++++ b/sound/pci/echoaudio/echoaudio.c +@@ -1970,8 +1970,8 @@ static int snd_echo_create(struct snd_ca + } + + /* constructor */ +-static int snd_echo_probe(struct pci_dev *pci, +- const struct pci_device_id *pci_id) ++static int __snd_echo_probe(struct pci_dev *pci, ++ const struct pci_device_id *pci_id) + { + static int dev; + struct snd_card *card; +@@ -2139,6 +2139,11 @@ static int snd_echo_probe(struct pci_dev + return 0; + } + ++static int snd_echo_probe(struct pci_dev *pci, ++ const struct pci_device_id *pci_id) ++{ ++ return snd_card_free_on_error(&pci->dev, __snd_echo_probe(pci, pci_id)); ++} + + + #if defined(CONFIG_PM_SLEEP) diff --git a/queue-5.17/alsa-emu10k1x-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-emu10k1x-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..365fd1b9b71 --- /dev/null +++ b/queue-5.17/alsa-emu10k1x-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From f37019b6bfe2e13cc536af0e6a42ed62005392ae Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:09 +0200 +Subject: ALSA: emu10k1x: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit f37019b6bfe2e13cc536af0e6a42ed62005392ae upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-13-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/emu10k1/emu10k1x.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/emu10k1/emu10k1x.c ++++ b/sound/pci/emu10k1/emu10k1x.c +@@ -1491,8 +1491,8 @@ static int snd_emu10k1x_midi(struct emu1 + 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 + 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) */ diff --git a/queue-5.17/alsa-ens137x-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-ens137x-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..4fd352f15cd --- /dev/null +++ b/queue-5.17/alsa-ens137x-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From c2dc46932d117a1505f589ad1db3095aa6789058 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:10 +0200 +Subject: ALSA: ens137x: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit c2dc46932d117a1505f589ad1db3095aa6789058 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-14-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/ens1370.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/ens1370.c ++++ b/sound/pci/ens1370.c +@@ -2304,8 +2304,8 @@ static irqreturn_t snd_audiopci_interrup + 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 + 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, diff --git a/queue-5.17/alsa-es1938-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-es1938-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..89850643e8d --- /dev/null +++ b/queue-5.17/alsa-es1938-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From bc22628591e5913e67edb3c2a89b97849e30a8f8 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:11 +0200 +Subject: ALSA: es1938: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit bc22628591e5913e67edb3c2a89b97849e30a8f8 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-15-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/es1938.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/es1938.c ++++ b/sound/pci/es1938.c +@@ -1716,8 +1716,8 @@ static int snd_es1938_mixer(struct es193 + } + + +-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_d + 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, diff --git a/queue-5.17/alsa-es1968-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-es1968-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..7775d8fe1bf --- /dev/null +++ b/queue-5.17/alsa-es1968-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From de9a01bc95a9e5e36d0659521bb04579053d8566 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:12 +0200 +Subject: ALSA: es1968: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit de9a01bc95a9e5e36d0659521bb04579053d8566 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-16-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/es1968.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/es1968.c ++++ b/sound/pci/es1968.c +@@ -2741,8 +2741,8 @@ static int snd_es1968_create(struct snd_ + + /* + */ +-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_d + 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, diff --git a/queue-5.17/alsa-fm801-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-fm801-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..1e87f1efc66 --- /dev/null +++ b/queue-5.17/alsa-fm801-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From 7f611274a3d1657a67b3fa8cd0cec1dee00e02b4 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:13 +0200 +Subject: ALSA: fm801: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 7f611274a3d1657a67b3fa8cd0cec1dee00e02b4 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-17-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/fm801.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/fm801.c ++++ b/sound/pci/fm801.c +@@ -1268,8 +1268,8 @@ static int snd_fm801_create(struct snd_c + 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 p + 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, diff --git a/queue-5.17/alsa-galaxy-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-galaxy-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..b759bc11f33 --- /dev/null +++ b/queue-5.17/alsa-galaxy-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,50 @@ +From 10b1881a97be240126891cb384bd3bc1869f52d8 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:25:58 +0200 +Subject: ALSA: galaxy: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 10b1881a97be240126891cb384bd3bc1869f52d8 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-2-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/isa/galaxy/galaxy.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/sound/isa/galaxy/galaxy.c ++++ b/sound/isa/galaxy/galaxy.c +@@ -478,7 +478,7 @@ static void snd_galaxy_free(struct snd_c + 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 devic + 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, diff --git a/queue-5.17/alsa-hdsp-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-hdsp-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..f63fd24f9b8 --- /dev/null +++ b/queue-5.17/alsa-hdsp-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From e2263f0bf7443a200a5c1c418baefd92f1674600 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:32 +0200 +Subject: ALSA: hdsp: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit e2263f0bf7443a200a5c1c418baefd92f1674600 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-36-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/rme9652/hdsp.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/rme9652/hdsp.c ++++ b/sound/pci/rme9652/hdsp.c +@@ -5444,17 +5444,21 @@ static int snd_hdsp_probe(struct pci_dev + 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 = { diff --git a/queue-5.17/alsa-hdspm-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-hdspm-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..997c5517818 --- /dev/null +++ b/queue-5.17/alsa-hdspm-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,56 @@ +From eab521aebcdeb1c801009503e3a7f8989e3c6b36 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:33 +0200 +Subject: ALSA: hdspm: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit eab521aebcdeb1c801009503e3a7f8989e3c6b36 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-37-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/rme9652/hdspm.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/rme9652/hdspm.c ++++ b/sound/pci/rme9652/hdspm.c +@@ -6895,7 +6895,7 @@ static int snd_hdspm_probe(struct pci_de + + 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_de + + 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 = { diff --git a/queue-5.17/alsa-ice1724-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-ice1724-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..fddb1f4999b --- /dev/null +++ b/queue-5.17/alsa-ice1724-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From 4a850a0079ce601c0c4016f4edb7d618e811ed7d Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:14 +0200 +Subject: ALSA: ice1724: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 4a850a0079ce601c0c4016f4edb7d618e811ed7d upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-18-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/ice1712/ice1724.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/ice1712/ice1724.c ++++ b/sound/pci/ice1712/ice1724.c +@@ -2519,8 +2519,8 @@ static int snd_vt1724_create(struct snd_ + * + */ + +-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_d + 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) + { diff --git a/queue-5.17/alsa-intel8x0-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-intel8x0-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..aefda53aa88 --- /dev/null +++ b/queue-5.17/alsa-intel8x0-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,80 @@ +From 71b21f5f8970a87f034138454ebeff0608d24875 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:15 +0200 +Subject: ALSA: intel8x0: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 71b21f5f8970a87f034138454ebeff0608d24875 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-19-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/intel8x0.c | 10 ++++++++-- + sound/pci/intel8x0m.c | 10 ++++++++-- + 2 files changed, 16 insertions(+), 4 deletions(-) + +--- a/sound/pci/intel8x0.c ++++ b/sound/pci/intel8x0.c +@@ -3109,8 +3109,8 @@ static int check_default_spdif_aclink(st + 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 + 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, +--- 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 pc + 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, diff --git a/queue-5.17/alsa-intel_hdmi-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-intel_hdmi-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..78cfac4c62d --- /dev/null +++ b/queue-5.17/alsa-intel_hdmi-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,50 @@ +From 5e154dfb4f9995096aa6d342df75040ae802c17e Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:23 +0200 +Subject: ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 5e154dfb4f9995096aa6d342df75040ae802c17e upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-27-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/x86/intel_hdmi_audio.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/sound/x86/intel_hdmi_audio.c ++++ b/sound/x86/intel_hdmi_audio.c +@@ -1665,7 +1665,7 @@ static void hdmi_lpe_audio_free(struct s + * 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; +@@ -1828,6 +1828,11 @@ static int hdmi_lpe_audio_probe(struct p + 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) + }; diff --git a/queue-5.17/alsa-korg1212-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-korg1212-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..17f0438295c --- /dev/null +++ b/queue-5.17/alsa-korg1212-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,54 @@ +From c01b723a56ce18ae66ff18c5803942badc15fbcd Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:16 +0200 +Subject: ALSA: korg1212: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit c01b723a56ce18ae66ff18c5803942badc15fbcd upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-20-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/korg1212/korg1212.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- 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 = { diff --git a/queue-5.17/alsa-lola-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-lola-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..c081058c73e --- /dev/null +++ b/queue-5.17/alsa-lola-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From d04e84b9817c652002f0ee9b42059d41493e9118 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:26 +0200 +Subject: ALSA: lola: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit d04e84b9817c652002f0ee9b42059d41493e9118 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-30-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/lola/lola.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/lola/lola.c ++++ b/sound/pci/lola/lola.c +@@ -637,8 +637,8 @@ static int lola_create(struct snd_card * + 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 *pc + 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) }, diff --git a/queue-5.17/alsa-lx6464es-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-lx6464es-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..f18bbd0e5c4 --- /dev/null +++ b/queue-5.17/alsa-lx6464es-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,56 @@ +From 60797a21dd8360a99ba797f8ca587087c07bb54c Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:30 +0200 +Subject: ALSA: lx6464es: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 60797a21dd8360a99ba797f8ca587087c07bb54c upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-34-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/lx6464es/lx6464es.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/lx6464es/lx6464es.c ++++ b/sound/pci/lx6464es/lx6464es.c +@@ -1019,7 +1019,7 @@ static int snd_lx6464es_probe(struct 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 + + 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 = { diff --git a/queue-5.17/alsa-maestro3-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-maestro3-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..746dc551c31 --- /dev/null +++ b/queue-5.17/alsa-maestro3-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From ae86bf5c2a8d81418eadf1c31dd9253b609e3093 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:17 +0200 +Subject: ALSA: maestro3: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit ae86bf5c2a8d81418eadf1c31dd9253b609e3093 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-21-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/maestro3.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/sound/pci/maestro3.c ++++ b/sound/pci/maestro3.c +@@ -2637,7 +2637,7 @@ snd_m3_create(struct snd_card *card, str + /* + */ + 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 + 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, diff --git a/queue-5.17/alsa-memalloc-add-fallback-sg-buffer-allocations-for-x86.patch b/queue-5.17/alsa-memalloc-add-fallback-sg-buffer-allocations-for-x86.patch new file mode 100644 index 00000000000..40eb39c2e81 --- /dev/null +++ b/queue-5.17/alsa-memalloc-add-fallback-sg-buffer-allocations-for-x86.patch @@ -0,0 +1,210 @@ +From 925ca893b4a65177394581737b95d03fea2660f2 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Wed, 13 Apr 2022 07:48:08 +0200 +Subject: ALSA: memalloc: Add fallback SG-buffer allocations for x86 + +From: Takashi Iwai + +commit 925ca893b4a65177394581737b95d03fea2660f2 upstream. + +The recent change for memory allocator replaced the SG-buffer handling +helper for x86 with the standard non-contiguous page handler. This +works for most cases, but there is a corner case I obviously +overlooked, namely, the fallback of non-contiguous handler without +IOMMU. When the system runs without IOMMU, the core handler tries to +use the continuous pages with a single SGL entry. It works nicely for +most cases, but when the system memory gets fragmented, the large +allocation may fail frequently. + +Ideally the non-contig handler could deal with the proper SG pages, +it's cumbersome to extend for now. As a workaround, here we add new +types for (minimalistic) SG allocations, instead, so that the +allocator falls back to those types automatically when the allocation +with the standard API failed. + +BTW, one better (but pretty minor) improvement from the previous +SG-buffer code is that this provides the proper mmap support without +the PCM's page fault handling. + +Fixes: 2c95b92ecd92 ("ALSA: memalloc: Unify x86 SG-buffer handling (take#3)") +BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2272 +BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1198248 +Cc: +Link: https://lore.kernel.org/r/20220413054808.7547-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + include/sound/memalloc.h | 5 ++ + sound/core/memalloc.c | 111 ++++++++++++++++++++++++++++++++++++++- + 2 files changed, 115 insertions(+), 1 deletion(-) + +diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h +index 653dfffb3ac8..8d79cebf95f3 100644 +--- a/include/sound/memalloc.h ++++ b/include/sound/memalloc.h +@@ -51,6 +51,11 @@ struct snd_dma_device { + #define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV /* no SG-buf support */ + #define SNDRV_DMA_TYPE_DEV_WC_SG SNDRV_DMA_TYPE_DEV_WC + #endif ++/* fallback types, don't use those directly */ ++#ifdef CONFIG_SND_DMA_SGBUF ++#define SNDRV_DMA_TYPE_DEV_SG_FALLBACK 10 ++#define SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK 11 ++#endif + + /* + * info for buffer allocation +diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c +index 6fd763d4d15b..15dc7160ba34 100644 +--- a/sound/core/memalloc.c ++++ b/sound/core/memalloc.c +@@ -499,6 +499,10 @@ static const struct snd_malloc_ops snd_dma_wc_ops = { + }; + #endif /* CONFIG_X86 */ + ++#ifdef CONFIG_SND_DMA_SGBUF ++static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size); ++#endif ++ + /* + * Non-contiguous pages allocator + */ +@@ -509,8 +513,18 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size) + + sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, + DEFAULT_GFP, 0); +- if (!sgt) ++ if (!sgt) { ++#ifdef CONFIG_SND_DMA_SGBUF ++ if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) ++ dmab->dev.type = SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK; ++ else ++ dmab->dev.type = SNDRV_DMA_TYPE_DEV_SG_FALLBACK; ++ return snd_dma_sg_fallback_alloc(dmab, size); ++#else + return NULL; ++#endif ++ } ++ + dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, + sg_dma_address(sgt->sgl)); + p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt); +@@ -633,6 +647,8 @@ static void *snd_dma_sg_wc_alloc(struct snd_dma_buffer *dmab, size_t size) + + if (!p) + return NULL; ++ if (dmab->dev.type != SNDRV_DMA_TYPE_DEV_WC_SG) ++ return p; + for_each_sgtable_page(sgt, &iter, 0) + set_memory_wc(sg_wc_address(&iter), 1); + return p; +@@ -665,6 +681,95 @@ static const struct snd_malloc_ops snd_dma_sg_wc_ops = { + .get_page = snd_dma_noncontig_get_page, + .get_chunk_size = snd_dma_noncontig_get_chunk_size, + }; ++ ++/* Fallback SG-buffer allocations for x86 */ ++struct snd_dma_sg_fallback { ++ size_t count; ++ struct page **pages; ++ dma_addr_t *addrs; ++}; ++ ++static void __snd_dma_sg_fallback_free(struct snd_dma_buffer *dmab, ++ struct snd_dma_sg_fallback *sgbuf) ++{ ++ size_t i; ++ ++ if (sgbuf->count && dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK) ++ set_pages_array_wb(sgbuf->pages, sgbuf->count); ++ for (i = 0; i < sgbuf->count && sgbuf->pages[i]; i++) ++ dma_free_coherent(dmab->dev.dev, PAGE_SIZE, ++ page_address(sgbuf->pages[i]), ++ sgbuf->addrs[i]); ++ kvfree(sgbuf->pages); ++ kvfree(sgbuf->addrs); ++ kfree(sgbuf); ++} ++ ++static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size) ++{ ++ struct snd_dma_sg_fallback *sgbuf; ++ struct page **pages; ++ size_t i, count; ++ void *p; ++ ++ sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); ++ if (!sgbuf) ++ return NULL; ++ count = PAGE_ALIGN(size) >> PAGE_SHIFT; ++ pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL); ++ if (!pages) ++ goto error; ++ sgbuf->pages = pages; ++ sgbuf->addrs = kvcalloc(count, sizeof(*sgbuf->addrs), GFP_KERNEL); ++ if (!sgbuf->addrs) ++ goto error; ++ ++ for (i = 0; i < count; sgbuf->count++, i++) { ++ p = dma_alloc_coherent(dmab->dev.dev, PAGE_SIZE, ++ &sgbuf->addrs[i], DEFAULT_GFP); ++ if (!p) ++ goto error; ++ sgbuf->pages[i] = virt_to_page(p); ++ } ++ ++ if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK) ++ set_pages_array_wc(pages, count); ++ p = vmap(pages, count, VM_MAP, PAGE_KERNEL); ++ if (!p) ++ goto error; ++ dmab->private_data = sgbuf; ++ return p; ++ ++ error: ++ __snd_dma_sg_fallback_free(dmab, sgbuf); ++ return NULL; ++} ++ ++static void snd_dma_sg_fallback_free(struct snd_dma_buffer *dmab) ++{ ++ vunmap(dmab->area); ++ __snd_dma_sg_fallback_free(dmab, dmab->private_data); ++} ++ ++static int snd_dma_sg_fallback_mmap(struct snd_dma_buffer *dmab, ++ struct vm_area_struct *area) ++{ ++ struct snd_dma_sg_fallback *sgbuf = dmab->private_data; ++ ++ if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK) ++ area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); ++ return vm_map_pages(area, sgbuf->pages, sgbuf->count); ++} ++ ++static const struct snd_malloc_ops snd_dma_sg_fallback_ops = { ++ .alloc = snd_dma_sg_fallback_alloc, ++ .free = snd_dma_sg_fallback_free, ++ .mmap = snd_dma_sg_fallback_mmap, ++ /* reuse vmalloc helpers */ ++ .get_addr = snd_dma_vmalloc_get_addr, ++ .get_page = snd_dma_vmalloc_get_page, ++ .get_chunk_size = snd_dma_vmalloc_get_chunk_size, ++}; + #endif /* CONFIG_SND_DMA_SGBUF */ + + /* +@@ -736,6 +841,10 @@ static const struct snd_malloc_ops *dma_ops[] = { + #ifdef CONFIG_GENERIC_ALLOCATOR + [SNDRV_DMA_TYPE_DEV_IRAM] = &snd_dma_iram_ops, + #endif /* CONFIG_GENERIC_ALLOCATOR */ ++#ifdef CONFIG_SND_DMA_SGBUF ++ [SNDRV_DMA_TYPE_DEV_SG_FALLBACK] = &snd_dma_sg_fallback_ops, ++ [SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK] = &snd_dma_sg_fallback_ops, ++#endif + #endif /* CONFIG_HAS_DMA */ + }; + +-- +2.35.2 + diff --git a/queue-5.17/alsa-oxygen-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-oxygen-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..30fa1fa46d0 --- /dev/null +++ b/queue-5.17/alsa-oxygen-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,55 @@ +From 6ebc16e206aa82ddb0450c907865c55bcb7c0f43 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:31 +0200 +Subject: ALSA: oxygen: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 6ebc16e206aa82ddb0450c907865c55bcb7c0f43 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-35-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/oxygen/oxygen_lib.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +--- 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_ + 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 + 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 diff --git a/queue-5.17/alsa-riptide-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-riptide-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..8fc939c81e9 --- /dev/null +++ b/queue-5.17/alsa-riptide-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From 348f08de55b149e41a05111d1a713c4484e5a426 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:18 +0200 +Subject: ALSA: riptide: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 348f08de55b149e41a05111d1a713c4484e5a426 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-22-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/riptide/riptide.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/sound/pci/riptide/riptide.c ++++ b/sound/pci/riptide/riptide.c +@@ -2023,7 +2023,7 @@ static void snd_riptide_joystick_remove( + #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 *p + 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, diff --git a/queue-5.17/alsa-rme32-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-rme32-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..cd5396f1813 --- /dev/null +++ b/queue-5.17/alsa-rme32-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,51 @@ +From 55d2d046b23b9bcb907f6b3e38e52113d55085eb Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:19 +0200 +Subject: ALSA: rme32: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 55d2d046b23b9bcb907f6b3e38e52113d55085eb upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-23-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/rme32.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/sound/pci/rme32.c ++++ b/sound/pci/rme32.c +@@ -1875,7 +1875,7 @@ static void snd_rme32_card_free(struct s + } + + 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, con + 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, diff --git a/queue-5.17/alsa-rme96-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-rme96-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..2c076d84976 --- /dev/null +++ b/queue-5.17/alsa-rme96-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From 93b884f8d82f08c7af542703a724cc23cd2d5bfc Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:20 +0200 +Subject: ALSA: rme96: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 93b884f8d82f08c7af542703a724cc23cd2d5bfc upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-24-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/rme96.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/rme96.c ++++ b/sound/pci/rme96.c +@@ -2430,8 +2430,8 @@ static void snd_rme96_card_free(struct s + } + + 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, diff --git a/queue-5.17/alsa-rme9652-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-rme9652-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..7ed5aff6378 --- /dev/null +++ b/queue-5.17/alsa-rme9652-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,54 @@ +From b2aa4f80693b7841e5ac4eadbd2d8cec56b10a51 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:34 +0200 +Subject: ALSA: rme9652: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit b2aa4f80693b7841e5ac4eadbd2d8cec56b10a51 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-38-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/rme9652/rme9652.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/sound/pci/rme9652/rme9652.c ++++ b/sound/pci/rme9652/rme9652.c +@@ -2572,7 +2572,7 @@ static int snd_rme9652_probe(struct 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_ + 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 = { diff --git a/queue-5.17/alsa-sc6000-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-sc6000-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..8186179fbf2 --- /dev/null +++ b/queue-5.17/alsa-sc6000-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,50 @@ +From d72458071150b802940204950d0d462ea3c913b1 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:25:59 +0200 +Subject: ALSA: sc6000: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit d72458071150b802940204950d0d462ea3c913b1 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-3-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/isa/sc6000.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/sound/isa/sc6000.c ++++ b/sound/isa/sc6000.c +@@ -537,7 +537,7 @@ static void snd_sc6000_free(struct snd_c + 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 devic + 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, diff --git a/queue-5.17/alsa-sonicvibes-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-sonicvibes-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..f014b02c8f7 --- /dev/null +++ b/queue-5.17/alsa-sonicvibes-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,53 @@ +From b087a381d7386ec95803222d0d9b1ac499550713 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:21 +0200 +Subject: ALSA: sonicvibes: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit b087a381d7386ec95803222d0d9b1ac499550713 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-25-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/sonicvibes.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/sound/pci/sonicvibes.c ++++ b/sound/pci/sonicvibes.c +@@ -1387,8 +1387,8 @@ static int snd_sonicvibes_midi(struct so + 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_de + 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, diff --git a/queue-5.17/alsa-usb-audio-cap-upper-limits-of-buffer-period-bytes-for-implicit-fb.patch b/queue-5.17/alsa-usb-audio-cap-upper-limits-of-buffer-period-bytes-for-implicit-fb.patch new file mode 100644 index 00000000000..368fa40a104 --- /dev/null +++ b/queue-5.17/alsa-usb-audio-cap-upper-limits-of-buffer-period-bytes-for-implicit-fb.patch @@ -0,0 +1,161 @@ +From 98c27add5d96485db731a92dac31567b0486cae8 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Thu, 7 Apr 2022 23:16:57 +0200 +Subject: ALSA: usb-audio: Cap upper limits of buffer/period bytes for implicit fb + +From: Takashi Iwai + +commit 98c27add5d96485db731a92dac31567b0486cae8 upstream. + +In the implicit feedback mode, some parameters are tied between both +playback and capture streams. One of the tied parameters is the +period size, and this can be a problem if the device has different +number of channels to both streams. Assume that an application opens +a playback stream that has an implicit feedback from a capture stream, +and it allocates up to the max period and buffer size as much as +possible. When the capture device supports only more channels than +the playback, the minimum period and buffer sizes become larger than +the sizes the playback stream took. That is, the minimum size will be +over the max size the driver limits, and PCM core sees as if no +available configuration is found, returning -EINVAL mercilessly. + +For avoiding this problem, we have to look through the counter part of +audioformat list for each sync ep, and checks the channels. If more +channels are found there, we reduce the max period and buffer sizes +accordingly. + +You may wonder that the patch adds only the evaluation of channels +between streams, and what about other parameters? Both the format and +the rate are tied in the implicit fb mode, hence they are always +identical. + +BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215792 +Fixes: 5a6c3e11c9c9 ("ALSA: usb-audio: Add hw constraint for implicit fb sync") +Cc: +Link: https://lore.kernel.org/r/20220407211657.15087-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/usb/pcm.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 87 insertions(+), 2 deletions(-) + +--- a/sound/usb/pcm.c ++++ b/sound/usb/pcm.c +@@ -659,6 +659,9 @@ static int snd_usb_pcm_prepare(struct sn + #define hwc_debug(fmt, args...) do { } while(0) + #endif + ++#define MAX_BUFFER_BYTES (1024 * 1024) ++#define MAX_PERIOD_BYTES (512 * 1024) ++ + static const struct snd_pcm_hardware snd_usb_hardware = + { + .info = SNDRV_PCM_INFO_MMAP | +@@ -669,9 +672,9 @@ static const struct snd_pcm_hardware snd + SNDRV_PCM_INFO_PAUSE, + .channels_min = 1, + .channels_max = 256, +- .buffer_bytes_max = 1024 * 1024, ++ .buffer_bytes_max = MAX_BUFFER_BYTES, + .period_bytes_min = 64, +- .period_bytes_max = 512 * 1024, ++ .period_bytes_max = MAX_PERIOD_BYTES, + .periods_min = 2, + .periods_max = 1024, + }; +@@ -971,6 +974,78 @@ static int hw_rule_periods_implicit_fb(s + ep->cur_buffer_periods); + } + ++/* get the adjusted max buffer (or period) bytes that can fit with the ++ * paired format for implicit fb ++ */ ++static unsigned int ++get_adjusted_max_bytes(struct snd_usb_substream *subs, ++ struct snd_usb_substream *pair, ++ struct snd_pcm_hw_params *params, ++ unsigned int max_bytes, ++ bool reverse_map) ++{ ++ const struct audioformat *fp, *pp; ++ unsigned int rmax = 0, r; ++ ++ list_for_each_entry(fp, &subs->fmt_list, list) { ++ if (!fp->implicit_fb) ++ continue; ++ if (!reverse_map && ++ !hw_check_valid_format(subs, params, fp)) ++ continue; ++ list_for_each_entry(pp, &pair->fmt_list, list) { ++ if (pp->iface != fp->sync_iface || ++ pp->altsetting != fp->sync_altsetting || ++ pp->ep_idx != fp->sync_ep_idx) ++ continue; ++ if (reverse_map && ++ !hw_check_valid_format(pair, params, pp)) ++ break; ++ if (!reverse_map && pp->channels > fp->channels) ++ r = max_bytes * fp->channels / pp->channels; ++ else if (reverse_map && pp->channels < fp->channels) ++ r = max_bytes * pp->channels / fp->channels; ++ else ++ r = max_bytes; ++ rmax = max(rmax, r); ++ break; ++ } ++ } ++ return rmax; ++} ++ ++/* Reduce the period or buffer bytes depending on the paired substream; ++ * when a paired configuration for implicit fb has a higher number of channels, ++ * we need to reduce the max size accordingly, otherwise it may become unusable ++ */ ++static int hw_rule_bytes_implicit_fb(struct snd_pcm_hw_params *params, ++ struct snd_pcm_hw_rule *rule) ++{ ++ struct snd_usb_substream *subs = rule->private; ++ struct snd_usb_substream *pair; ++ struct snd_interval *it; ++ unsigned int max_bytes; ++ unsigned int rmax; ++ ++ pair = &subs->stream->substream[!subs->direction]; ++ if (!pair->ep_num) ++ return 0; ++ ++ if (rule->var == SNDRV_PCM_HW_PARAM_PERIOD_BYTES) ++ max_bytes = MAX_PERIOD_BYTES; ++ else ++ max_bytes = MAX_BUFFER_BYTES; ++ ++ rmax = get_adjusted_max_bytes(subs, pair, params, max_bytes, false); ++ if (!rmax) ++ rmax = get_adjusted_max_bytes(pair, subs, params, max_bytes, true); ++ if (!rmax) ++ return 0; ++ ++ it = hw_param_interval(params, rule->var); ++ return apply_hw_params_minmax(it, 0, rmax); ++} ++ + /* + * set up the runtime hardware information. + */ +@@ -1085,6 +1160,16 @@ static int setup_hw_info(struct snd_pcm_ + SNDRV_PCM_HW_PARAM_PERIODS, -1); + if (err < 0) + return err; ++ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, ++ hw_rule_bytes_implicit_fb, subs, ++ SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1); ++ if (err < 0) ++ return err; ++ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, ++ hw_rule_bytes_implicit_fb, subs, ++ SNDRV_PCM_HW_PARAM_PERIOD_BYTES, -1); ++ if (err < 0) ++ return err; + + list_for_each_entry(fp, &subs->fmt_list, list) { + if (fp->implicit_fb) { diff --git a/queue-5.17/alsa-via82xx-fix-the-missing-snd_card_free-call-at-probe-error.patch b/queue-5.17/alsa-via82xx-fix-the-missing-snd_card_free-call-at-probe-error.patch new file mode 100644 index 00000000000..2e10aaecc9b --- /dev/null +++ b/queue-5.17/alsa-via82xx-fix-the-missing-snd_card_free-call-at-probe-error.patch @@ -0,0 +1,80 @@ +From 27a0963f9cea5be3c68281f07fe82cdf712ef333 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 12 Apr 2022 12:26:22 +0200 +Subject: ALSA: via82xx: Fix the missing snd_card_free() call at probe error + +From: Takashi Iwai + +commit 27a0963f9cea5be3c68281f07fe82cdf712ef333 upstream. + +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: +Link: https://lore.kernel.org/r/20220412102636.16000-26-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/via82xx.c | 10 ++++++++-- + sound/pci/via82xx_modem.c | 10 ++++++++-- + 2 files changed, 16 insertions(+), 4 deletions(-) + +--- a/sound/pci/via82xx.c ++++ b/sound/pci/via82xx.c +@@ -2458,8 +2458,8 @@ static int check_dxs_list(struct pci_dev + 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_ + 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, +--- a/sound/pci/via82xx_modem.c ++++ b/sound/pci/via82xx_modem.c +@@ -1103,8 +1103,8 @@ static int snd_via82xx_create(struct snd + } + + +-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_ + 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, diff --git a/queue-5.17/series b/queue-5.17/series index 4887c5374ac..170c51e56c9 100644 --- a/queue-5.17/series +++ b/queue-5.17/series @@ -16,3 +16,41 @@ btrfs-fix-btrfs_submit_compressed_write-cgroup-attribution.patch btrfs-return-allocated-block-group-from-do_chunk_alloc.patch alsa-core-add-snd_card_free_on_error-helper.patch alsa-sis7019-fix-the-missing-error-handling.patch +alsa-ali5451-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-als300-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-als4000-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-atiixp-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-au88x0-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-aw2-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-azt3328-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-bt87x-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-ca0106-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-cmipci-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-cs4281-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-cs5535audio-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-echoaudio-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-emu10k1x-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-ens137x-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-es1938-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-es1968-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-fm801-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-galaxy-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-hdsp-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-hdspm-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-ice1724-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-intel8x0-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-intel_hdmi-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-korg1212-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-lola-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-lx6464es-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-maestro3-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-oxygen-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-riptide-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-rme32-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-rme9652-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-rme96-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-sc6000-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-sonicvibes-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-via82xx-fix-the-missing-snd_card_free-call-at-probe-error.patch +alsa-usb-audio-cap-upper-limits-of-buffer-period-bytes-for-implicit-fb.patch +alsa-memalloc-add-fallback-sg-buffer-allocations-for-x86.patch