lkml.org 
[lkml]   [2021]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH/RFC 2/2] ALSA: firewire-tascam: Fix integer overflow in midi_port_work()
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 1000000000L, 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 integer constant.
>
> Note that this assumes port->consume_bytes <= 16777.
>
> Fixes: 531f471834227d03 ("ALSA: firewire-lib/firewire-tascam: localize async midi port")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
>
> I don't know the maximum transfer length of MIDI, but given it's an old
> standard, I guess it's rather small. If it is larger than 16777, the
> constant "8" should be replaced by "8ULL", to force 64-bit arithmetic.

Applied now. Thanks.


Takashi

\
 
 \ /
  Last update: 2021-01-12 15:02    [W:1.169 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site