mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ALSA: 6fire: Release resources at card release
[ Upstream commit a0810c3d6dd2d29a9b92604d682eacd2902ce947 ]
The current 6fire code tries to release the resources right after the
call of usb6fire_chip_abort(). But at this moment, the card object
might be still in use (as we're calling snd_card_free_when_closed()).
For avoid potential UAFs, move the release of resources to the card's
private_free instead of the manual call of usb6fire_chip_destroy() at
the USB disconnect callback.
Fixes: c6d43ba816 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20241113111042.15058-6-tiwai@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
237f3faf01
commit
ea8cc56db6
@@ -61,8 +61,10 @@ static void usb6fire_chip_abort(struct sfire_chip *chip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usb6fire_chip_destroy(struct sfire_chip *chip)
|
static void usb6fire_card_free(struct snd_card *card)
|
||||||
{
|
{
|
||||||
|
struct sfire_chip *chip = card->private_data;
|
||||||
|
|
||||||
if (chip) {
|
if (chip) {
|
||||||
if (chip->pcm)
|
if (chip->pcm)
|
||||||
usb6fire_pcm_destroy(chip);
|
usb6fire_pcm_destroy(chip);
|
||||||
@@ -72,8 +74,6 @@ static void usb6fire_chip_destroy(struct sfire_chip *chip)
|
|||||||
usb6fire_comm_destroy(chip);
|
usb6fire_comm_destroy(chip);
|
||||||
if (chip->control)
|
if (chip->control)
|
||||||
usb6fire_control_destroy(chip);
|
usb6fire_control_destroy(chip);
|
||||||
if (chip->card)
|
|
||||||
snd_card_free(chip->card);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +136,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
|
|||||||
chip->regidx = regidx;
|
chip->regidx = regidx;
|
||||||
chip->intf_count = 1;
|
chip->intf_count = 1;
|
||||||
chip->card = card;
|
chip->card = card;
|
||||||
|
card->private_free = usb6fire_card_free;
|
||||||
|
|
||||||
ret = usb6fire_comm_init(chip);
|
ret = usb6fire_comm_init(chip);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -162,7 +163,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
destroy_chip:
|
destroy_chip:
|
||||||
usb6fire_chip_destroy(chip);
|
snd_card_free(card);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +182,6 @@ static void usb6fire_chip_disconnect(struct usb_interface *intf)
|
|||||||
|
|
||||||
chip->shutdown = true;
|
chip->shutdown = true;
|
||||||
usb6fire_chip_abort(chip);
|
usb6fire_chip_abort(chip);
|
||||||
usb6fire_chip_destroy(chip);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user