提交 9a932145 编写于 作者: D Dan Carpenter 提交者: Dmitry Torokhov

Input: ff-memless - fix a couple min_t() casts

envelope->attack_level is a u16 type.  We're trying to clamp it here
so it's between 0 and 0x7fff.  Unfortunately, the cast to __s16 turns
all the values larger than 0x7fff into negative numbers and min_t()
thinks they are less than 0x7fff.  envelope_level is an int so now
we've got negative values stored there.
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
上级 c6bd9d46
...@@ -176,7 +176,7 @@ static int apply_envelope(struct ml_effect_state *state, int value, ...@@ -176,7 +176,7 @@ static int apply_envelope(struct ml_effect_state *state, int value,
value, envelope->attack_level); value, envelope->attack_level);
time_from_level = jiffies_to_msecs(now - state->play_at); time_from_level = jiffies_to_msecs(now - state->play_at);
time_of_envelope = envelope->attack_length; time_of_envelope = envelope->attack_length;
envelope_level = min_t(__s16, envelope->attack_level, 0x7fff); envelope_level = min_t(u16, envelope->attack_level, 0x7fff);
} else if (envelope->fade_length && effect->replay.length && } else if (envelope->fade_length && effect->replay.length &&
time_after(now, time_after(now,
...@@ -184,7 +184,7 @@ static int apply_envelope(struct ml_effect_state *state, int value, ...@@ -184,7 +184,7 @@ static int apply_envelope(struct ml_effect_state *state, int value,
time_before(now, state->stop_at)) { time_before(now, state->stop_at)) {
time_from_level = jiffies_to_msecs(state->stop_at - now); time_from_level = jiffies_to_msecs(state->stop_at - now);
time_of_envelope = envelope->fade_length; time_of_envelope = envelope->fade_length;
envelope_level = min_t(__s16, envelope->fade_level, 0x7fff); envelope_level = min_t(u16, envelope->fade_level, 0x7fff);
} else } else
return value; return value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册