diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2018-04-08 05:02:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-23 07:40:15 -0400 |
commit | e33bbe69149b802c0c77bfb822685772f85388ca (patch) | |
tree | 2e7435326efad5203215da05726c69c5696498be | |
parent | 4aa403b775fc027ee86d9a090a4c5c3ee9063089 (diff) |
slimbus: Fix out-of-bounds access in slim_slicesize()
With gcc-4.1.2:
slimbus/messaging.c: In function ‘slim_slicesize’:
slimbus/messaging.c:186: warning: statement with no effect
Indeed, clamp() is a macro not operating in-place, but returning the
clamped value. Hence the value is not clamped at all, which may lead to
an out-of-bounds access.
Fix this by assigning the clamped value.
Fixes: afbdcc7c384b0d44 ("slimbus: Add messaging APIs to slimbus framework")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/slimbus/messaging.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index 884419c37e84..457ea1f8db30 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c | |||
@@ -183,7 +183,7 @@ static u16 slim_slicesize(int code) | |||
183 | 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7 | 183 | 0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7 |
184 | }; | 184 | }; |
185 | 185 | ||
186 | clamp(code, 1, (int)ARRAY_SIZE(sizetocode)); | 186 | code = clamp(code, 1, (int)ARRAY_SIZE(sizetocode)); |
187 | 187 | ||
188 | return sizetocode[code - 1]; | 188 | return sizetocode[code - 1]; |
189 | } | 189 | } |