aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorDan Carpenter <[email protected]>2023-06-30 12:46:53 +0300
committerAnna Schumaker <[email protected]>2023-08-24 13:24:15 -0400
commite87cf8a28e7592bd19064e8181324ae26bc02932 (patch)
tree6e00a7c2bf7387e4f83f0c8d9cbd29bd27a4acf0 /include/linux
parentf9597ba8872a8f79f97b712ca098ffec841a374c (diff)
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 <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sunrpc/xdr.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index adc844db1ea5..68915180a29c 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)