diff options
Diffstat (limited to 'include/linux/overflow.h')
-rw-r--r-- | include/linux/overflow.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/overflow.h b/include/linux/overflow.h index 40b48e2133cb..6534a727cadb 100644 --- a/include/linux/overflow.h +++ b/include/linux/overflow.h | |||
@@ -278,11 +278,15 @@ static inline __must_check size_t array3_size(size_t a, size_t b, size_t c) | |||
278 | return bytes; | 278 | return bytes; |
279 | } | 279 | } |
280 | 280 | ||
281 | static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c) | 281 | /* |
282 | * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for | ||
283 | * struct_size() below. | ||
284 | */ | ||
285 | static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c) | ||
282 | { | 286 | { |
283 | size_t bytes; | 287 | size_t bytes; |
284 | 288 | ||
285 | if (check_mul_overflow(n, size, &bytes)) | 289 | if (check_mul_overflow(a, b, &bytes)) |
286 | return SIZE_MAX; | 290 | return SIZE_MAX; |
287 | if (check_add_overflow(bytes, c, &bytes)) | 291 | if (check_add_overflow(bytes, c, &bytes)) |
288 | return SIZE_MAX; | 292 | return SIZE_MAX; |