Re: [PATCH/RFC 1/2] ALSA: fireface: Fix integer overflow in transmit_midi_msg()

2021-01-12 Thread Takashi Iwai
On Mon, 11 Jan 2021 14:02:50 +0100, Geert Uytterhoeven wrote: > > As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 10L, > the second multiplication in > > ff->rx_bytes[port] * 8 * NSEC_PER_SEC / 31250 > > always overflows on 32-bit platforms, truncating the result. Fix this

Re: [PATCH/RFC 1/2] ALSA: fireface: Fix integer overflow in transmit_midi_msg()

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

[PATCH/RFC 1/2] ALSA: fireface: Fix integer overflow in transmit_midi_msg()

2021-01-11 Thread Geert Uytterhoeven
As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 10L, the second multiplication in ff->rx_bytes[port] * 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 integer constant. Not