Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

include/linux/byteorder/generic.h: fix index variables

In cpu_to_be32_array() and be32_to_cpu_array() the length of the array is
given by variable len of type size_t. An index variable of type int is used
to iterate over the array. This is bound to fail for len > INT_MAX and
lets GCC add instructions for sign extension.

Correct the type of the index variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Link: https://lore.kernel.org/r/20210523204958.64575-1-xypron.glpk@gmx.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heinrich Schuchardt and committed by
Greg Kroah-Hartman
b4c80629 f4d77525

+2 -2
+2 -2
include/linux/byteorder/generic.h
··· 190 190 191 191 static inline void cpu_to_be32_array(__be32 *dst, const u32 *src, size_t len) 192 192 { 193 - int i; 193 + size_t i; 194 194 195 195 for (i = 0; i < len; i++) 196 196 dst[i] = cpu_to_be32(src[i]); ··· 198 198 199 199 static inline void be32_to_cpu_array(u32 *dst, const __be32 *src, size_t len) 200 200 { 201 - int i; 201 + size_t i; 202 202 203 203 for (i = 0; i < len; i++) 204 204 dst[i] = be32_to_cpu(src[i]);