Skip to content

Commit 8b449e9

Browse files
tiwaigregkh
authored andcommitted
ALSA: line6: Fix write on zero-sized buffer
commit 3450121 upstream. LINE6 drivers allocate the buffers based on the value returned from usb_maxpacket() calls. The manipulated device may return zero for this, and this results in the kmalloc() with zero size (and it may succeed) while the other part of the driver code writes the packet data with the fixed size -- which eventually overwrites. This patch adds a simple sanity check for the invalid buffer size for avoiding that problem. Reported-by: [email protected] Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e25f837 commit 8b449e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sound/usb/line6/pcm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,11 @@ int line6_init_pcm(struct usb_line6 *line6,
558558
line6pcm->max_packet_size_out =
559559
usb_maxpacket(line6->usbdev,
560560
usb_sndisocpipe(line6->usbdev, ep_write), 1);
561+
if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {
562+
dev_err(line6pcm->line6->ifcdev,
563+
"cannot get proper max packet size\n");
564+
return -EINVAL;
565+
}
561566

562567
spin_lock_init(&line6pcm->out.lock);
563568
spin_lock_init(&line6pcm->in.lock);

0 commit comments

Comments
 (0)