Skip to content

Commit a0810c3

Browse files
committed
ALSA: 6fire: Release resources at card release
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: c6d43ba ("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
1 parent b04dcbb commit a0810c3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sound/usb/6fire/chip.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ static void usb6fire_chip_abort(struct sfire_chip *chip)
6161
}
6262
}
6363

64-
static void usb6fire_chip_destroy(struct sfire_chip *chip)
64+
static void usb6fire_card_free(struct snd_card *card)
6565
{
66+
struct sfire_chip *chip = card->private_data;
67+
6668
if (chip) {
6769
if (chip->pcm)
6870
usb6fire_pcm_destroy(chip);
@@ -72,8 +74,6 @@ static void usb6fire_chip_destroy(struct sfire_chip *chip)
7274
usb6fire_comm_destroy(chip);
7375
if (chip->control)
7476
usb6fire_control_destroy(chip);
75-
if (chip->card)
76-
snd_card_free(chip->card);
7777
}
7878
}
7979

@@ -136,6 +136,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
136136
chip->regidx = regidx;
137137
chip->intf_count = 1;
138138
chip->card = card;
139+
card->private_free = usb6fire_card_free;
139140

140141
ret = usb6fire_comm_init(chip);
141142
if (ret < 0)
@@ -162,7 +163,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
162163
return 0;
163164

164165
destroy_chip:
165-
usb6fire_chip_destroy(chip);
166+
snd_card_free(card);
166167
return ret;
167168
}
168169

@@ -181,7 +182,6 @@ static void usb6fire_chip_disconnect(struct usb_interface *intf)
181182

182183
chip->shutdown = true;
183184
usb6fire_chip_abort(chip);
184-
usb6fire_chip_destroy(chip);
185185
}
186186
}
187187
}

0 commit comments

Comments
 (0)