ALSA: ymfpci: Fix the missing snd_card_free() call at probe error
PATCH 1/1 ALSA: ymfpci: Fix the missing snd_card_free() call at probe error
Like a few other drivers, YMFPCI driver needs to clean up with snd_card_free() call at an error path of the probe; otherwise the other devres resources are released before the card and it results in the UAF.
This patch uses the helper for handling the probe error gracefully.
Fixes f33fc1576757 ("ALSA: ymfpci: Create card with device-managed snd_devm_card_new()")
Cc <[email protected]>
Reported-and-tested-by Takashi Yano <[email protected]>
Signed-off-by Takashi Iwai <[email protected]>
--- sound/pci/ymfpci/ymfpci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/pci/ymfpci/ymfpci.c +8 -2
@@ -152,8 +152,8 @@ static inline int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, ivoid snd_ymfpci_free_gameport (struct snd_ymfpci *chip) { }#endif /* SUPPORT_JOYSTICK */ -static int snd_card_ymfpci_probe (struct pci_dev *pci, -const struct pci_device_id *pci_id) +static int __snd_card_ymfpci_probe (struct pci_dev *pci, +const struct pci_device_id *pci_id) {static int dev;struct snd_card *card;
@@ -348,6 +348,12 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,return 0 ; } +static int snd_card_ymfpci_probe (struct pci_dev *pci, +const struct pci_device_id *pci_id) +{ +return snd_card_free_on_error (&pci->dev,__snd_card_ymfpci_probe (pci, pci_id)); +} +static struct pci_driver ymfpci_driver = { .name =KBUILD_MODNAME , .id_table = snd_ymfpci_ids,
Signature · 1 line
2.35.3