linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] microblaze: Prevent the overflow of the start
@ 2020-01-14 12:34 Michal Simek
  2020-02-04 10:34 ` Michal Simek
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Simek @ 2020-01-14 12:34 UTC (permalink / raw)
  To: linux-kernel, monstr, michal.simek, git; +Cc: Shubhrajyoti Datta

From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>

In case the start + cache size is more than the max int the
start overflows.
Prevent the same.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 arch/microblaze/kernel/cpu/cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/microblaze/kernel/cpu/cache.c b/arch/microblaze/kernel/cpu/cache.c
index 0bde47e4fa69..dcba53803fa5 100644
--- a/arch/microblaze/kernel/cpu/cache.c
+++ b/arch/microblaze/kernel/cpu/cache.c
@@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)
 #define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size)	\
 do {									\
 	int align = ~(cache_line_length - 1);				\
-	end = min(start + cache_size, end);				\
+	if (start <  UINT_MAX - cache_size)				\
+		end = min(start + cache_size, end);			\
 	start &= align;							\
 } while (0)
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] microblaze: Prevent the overflow of the start
  2020-01-14 12:34 [PATCH] microblaze: Prevent the overflow of the start Michal Simek
@ 2020-02-04 10:34 ` Michal Simek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Simek @ 2020-02-04 10:34 UTC (permalink / raw)
  To: LKML, Michal Simek, git; +Cc: Shubhrajyoti Datta

út 14. 1. 2020 v 13:34 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>
> In case the start + cache size is more than the max int the
> start overflows.
> Prevent the same.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>  arch/microblaze/kernel/cpu/cache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/microblaze/kernel/cpu/cache.c b/arch/microblaze/kernel/cpu/cache.c
> index 0bde47e4fa69..dcba53803fa5 100644
> --- a/arch/microblaze/kernel/cpu/cache.c
> +++ b/arch/microblaze/kernel/cpu/cache.c
> @@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)
>  #define CACHE_LOOP_LIMITS(start, end, cache_line_length, cache_size)   \
>  do {                                                                   \
>         int align = ~(cache_line_length - 1);                           \
> -       end = min(start + cache_size, end);                             \
> +       if (start <  UINT_MAX - cache_size)                             \
> +               end = min(start + cache_size, end);                     \
>         start &= align;                                                 \
>  } while (0)
>
> --
> 2.24.0
>

Applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-04 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 12:34 [PATCH] microblaze: Prevent the overflow of the start Michal Simek
2020-02-04 10:34 ` Michal Simek

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).