Re: [PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

2021-01-12 Thread Takashi Iwai
On Mon, 11 Jan 2021 14:02:51 +0100, Geert Uytterhoeven wrote: > > As snd_fw_async_midi_port.consume_bytes is unsigned int, and > NSEC_PER_SEC is 10L, the second multiplication in > > port->consume_bytes * 8 * NSEC_PER_SEC / 31250 > > always overflows on 32-bit platforms, truncating

Re: [PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

2021-01-12 Thread Geert Uytterhoeven
Hi Sakamoto-san, On Tue, Jan 12, 2021 at 2:43 PM Takashi Sakamoto wrote: > On Mon, Jan 11, 2021 at 02:02:51PM +0100, Geert Uytterhoeven wrote: > > As snd_fw_async_midi_port.consume_bytes is unsigned int, and > > NSEC_PER_SEC is 10L, the second multiplication in > > > >

Re: [PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

2021-01-12 Thread Takashi Sakamoto
Hi, On Mon, Jan 11, 2021 at 02:02:51PM +0100, Geert Uytterhoeven wrote: > As snd_fw_async_midi_port.consume_bytes is unsigned int, and > NSEC_PER_SEC is 10L, the second multiplication in > > port->consume_bytes * 8 * NSEC_PER_SEC / 31250 > > always overflows on 32-bit platforms,

[PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

2021-01-11 Thread Geert Uytterhoeven
As snd_fw_async_midi_port.consume_bytes is unsigned int, and NSEC_PER_SEC is 10L, the second multiplication in port->consume_bytes * 8 * NSEC_PER_SEC / 31250 always overflows on 32-bit platforms, truncating the result. Fix this by precalculating "NSEC_PER_SEC / 31250", which is an