Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: rme9652: Fix the missing snd_card_free() call at probe error

The previous cleanup with devres may lead to the incorrect release
orders at the probe error handling due to the devres's nature. Until
we register the card, snd_card_free() has to be called at first for
releasing the stuff properly when the driver tries to manage and
release the stuff via card->private_free().

This patch fixes it by calling snd_card_free() manually on the error
from the probe callback.

Fixes: b1002b2d41c5 ("ALSA: rme9652: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220412102636.16000-38-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+6 -2
+6 -2
sound/pci/rme9652/rme9652.c
··· 2572 2572 rme9652->pci = pci; 2573 2573 err = snd_rme9652_create(card, rme9652, precise_ptr[dev]); 2574 2574 if (err) 2575 - return err; 2575 + goto error; 2576 2576 2577 2577 strcpy(card->shortname, rme9652->card_name); 2578 2578 ··· 2580 2580 card->shortname, rme9652->port, rme9652->irq); 2581 2581 err = snd_card_register(card); 2582 2582 if (err) 2583 - return err; 2583 + goto error; 2584 2584 pci_set_drvdata(pci, card); 2585 2585 dev++; 2586 2586 return 0; 2587 + 2588 + error: 2589 + snd_card_free(card); 2590 + return err; 2587 2591 } 2588 2592 2589 2593 static struct pci_driver rme9652_driver = {