* [PATCH] clk: stm32: Fix out-by-one error path in the index lookup
@ 2015-06-28 9:55 Daniel Thompson
2015-06-29 8:50 ` Maxime Coquelin
2015-07-02 16:55 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Thompson @ 2015-06-28 9:55 UTC (permalink / raw)
To: Mike Turquette, Stephen Boyd
Cc: Daniel Thompson, Maxime Coquelin, linux-clk, linux-kernel,
patches, linaro-kernel
If stm32f4_rcc_lookup() is called with primary == 0 and secondary == 192
then it will read beyond the end of the table array due to an out-by-one
error in the range check.
In addition to the fixing the inequality we also modify the r.h.s. to
make it even more explicit that we are comparing against the size of
table in bits.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
---
drivers/clk/clk-stm32f4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
index c825bbd..148c151 100644
--- a/drivers/clk/clk-stm32f4.c
+++ b/drivers/clk/clk-stm32f4.c
@@ -268,7 +268,7 @@ static int stm32f4_rcc_lookup_clk_idx(u8 primary, u8 secondary)
memcpy(table, stm32f42xx_gate_map, sizeof(table));
/* only bits set in table can be used as indices */
- if (WARN_ON(secondary > 8 * sizeof(table) ||
+ if (WARN_ON(secondary >= BITS_PER_BYTE * sizeof(table) ||
0 == (table[BIT_ULL_WORD(secondary)] &
BIT_ULL_MASK(secondary))))
return -EINVAL;
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: stm32: Fix out-by-one error path in the index lookup
2015-06-28 9:55 [PATCH] clk: stm32: Fix out-by-one error path in the index lookup Daniel Thompson
@ 2015-06-29 8:50 ` Maxime Coquelin
2015-07-02 16:55 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2015-06-29 8:50 UTC (permalink / raw)
To: Daniel Thompson
Cc: Mike Turquette, Stephen Boyd, linux-clk,
linux-kernel@vger.kernel.org, patches, linaro-kernel
Hi Daniel,
2015-06-28 11:55 GMT+02:00 Daniel Thompson <daniel.thompson@linaro.org>:
> If stm32f4_rcc_lookup() is called with primary == 0 and secondary == 192
> then it will read beyond the end of the table array due to an out-by-one
> error in the range check.
>
> In addition to the fixing the inequality we also modify the r.h.s. to
> make it even more explicit that we are comparing against the size of
> table in bits.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
> drivers/clk/clk-stm32f4.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Thanks for the patch.
Acked-by: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Regards,
Maxime
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: stm32: Fix out-by-one error path in the index lookup
2015-06-28 9:55 [PATCH] clk: stm32: Fix out-by-one error path in the index lookup Daniel Thompson
2015-06-29 8:50 ` Maxime Coquelin
@ 2015-07-02 16:55 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2015-07-02 16:55 UTC (permalink / raw)
To: Daniel Thompson
Cc: Mike Turquette, Maxime Coquelin, linux-clk, linux-kernel, patches,
linaro-kernel
On 06/28, Daniel Thompson wrote:
> If stm32f4_rcc_lookup() is called with primary == 0 and secondary == 192
> then it will read beyond the end of the table array due to an out-by-one
> error in the range check.
>
> In addition to the fixing the inequality we also modify the r.h.s. to
> make it even more explicit that we are comparing against the size of
> table in bits.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
Applied to clk-fixes
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-02 16:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-28 9:55 [PATCH] clk: stm32: Fix out-by-one error path in the index lookup Daniel Thompson
2015-06-29 8:50 ` Maxime Coquelin
2015-07-02 16:55 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).