From: Dan Carpenter Date: Fri, 30 Jun 2023 09:46:53 +0000 (+0300) Subject: SUNRPC: clean up integer overflow check X-Git-Tag: v6.6.7~2024^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e87cf8a28e7592bd19064e8181324ae26bc02932;p=platform%2Fkernel%2Flinux-starfive.git SUNRPC: clean up integer overflow check This integer overflow check works as intended but Clang and GCC and warn about it when compiling with W=1. include/linux/sunrpc/xdr.h:539:17: error: comparison is always false due to limited range of data type [-Werror=type-limits] Use size_mul() to prevent the integer overflow. It silences the warning and it's cleaner as well. Reported-by: Dmitry Antipov Closes: https://lore.kernel.org/all/20230601143332.255312-1-dmantipov@yandex.ru/ Signed-off-by: Dan Carpenter Acked-by: Jeff Layton Signed-off-by: Anna Schumaker --- diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index adc844d..6891518 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -777,9 +777,7 @@ xdr_stream_decode_uint32_array(struct xdr_stream *xdr, if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0)) return -EBADMSG; - if (len > SIZE_MAX / sizeof(*p)) - return -EBADMSG; - p = xdr_inline_decode(xdr, len * sizeof(*p)); + p = xdr_inline_decode(xdr, size_mul(len, sizeof(*p))); if (unlikely(!p)) return -EBADMSG; if (array == NULL)