aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/overflow.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/overflow.h')
-rw-r--r--include/linux/overflow.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 15eb85de9226..659045046468 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -284,11 +284,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
284 return bytes; 284 return bytes;
285} 285}
286 286
287static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c) 287/*
288 * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
289 * struct_size() below.
290 */
291static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
288{ 292{
289 size_t bytes; 293 size_t bytes;
290 294
291 if (check_mul_overflow(n, size, &bytes)) 295 if (check_mul_overflow(a, b, &bytes))
292 return SIZE_MAX; 296 return SIZE_MAX;
293 if (check_add_overflow(bytes, c, &bytes)) 297 if (check_add_overflow(bytes, c, &bytes))
294 return SIZE_MAX; 298 return SIZE_MAX;