Skip to content

Commit 05ca447

Browse files
committedMay 19, 2021
ALSA: line6: Fix racy initialization of LINE6 MIDI
The initialization of MIDI devices that are found on some LINE6 drivers are currently done in a racy way; namely, the MIDI buffer instance is allocated and initialized in each private_init callback while the communication with the interface is already started via line6_init_cap_control() call before that point. This may lead to Oops in line6_data_received() when a spurious event is received, as reported by syzkaller. This patch moves the MIDI initialization to line6_init_cap_control() as well instead of the too-lately-called private_init for avoiding the race. Also this reduces slightly more lines, so it's a win-win change. Reported-by: [email protected] Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/20210517132725.GA50495@hyeyoo Cc: Hyeonggon Yoo <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 4c6fe8c commit 05ca447

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed
 

‎sound/usb/line6/driver.c

+4
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,10 @@ static int line6_init_cap_control(struct usb_line6 *line6)
699699
line6->buffer_message = kmalloc(LINE6_MIDI_MESSAGE_MAXLEN, GFP_KERNEL);
700700
if (!line6->buffer_message)
701701
return -ENOMEM;
702+
703+
ret = line6_init_midi(line6);
704+
if (ret < 0)
705+
return ret;
702706
} else {
703707
ret = line6_hwdep_init(line6);
704708
if (ret < 0)

‎sound/usb/line6/pod.c

-5
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,6 @@ static int pod_init(struct usb_line6 *line6,
376376
if (err < 0)
377377
return err;
378378

379-
/* initialize MIDI subsystem: */
380-
err = line6_init_midi(line6);
381-
if (err < 0)
382-
return err;
383-
384379
/* initialize PCM subsystem: */
385380
err = line6_init_pcm(line6, &pod_pcm_properties);
386381
if (err < 0)

‎sound/usb/line6/variax.c

-6
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ static int variax_init(struct usb_line6 *line6,
159159
const struct usb_device_id *id)
160160
{
161161
struct usb_line6_variax *variax = line6_to_variax(line6);
162-
int err;
163162

164163
line6->process_message = line6_variax_process_message;
165164
line6->disconnect = line6_variax_disconnect;
@@ -172,11 +171,6 @@ static int variax_init(struct usb_line6 *line6,
172171
if (variax->buffer_activate == NULL)
173172
return -ENOMEM;
174173

175-
/* initialize MIDI subsystem: */
176-
err = line6_init_midi(&variax->line6);
177-
if (err < 0)
178-
return err;
179-
180174
/* initiate startup procedure: */
181175
schedule_delayed_work(&line6->startup_work,
182176
msecs_to_jiffies(VARIAX_STARTUP_DELAY1));

0 commit comments

Comments
 (0)
Please sign in to comment.