Blob Blame History Raw
From b640a25a4835d84c136dd362bac4fd59f20ffc2e Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Wed, 26 Oct 2022 17:47:47 +0200
Subject: [PATCH] overflow.h: restore __ab_c_size
Patch-mainline: Never (kABI fixup)
References: git-fixes

The function was eliminated though it is available to code
using the include.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 include/linux/overflow.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index d1dd039fe..1b57545cb 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -371,4 +371,15 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
 #define struct_size(p, member, count)					\
 	size_add(sizeof(*(p)), flex_array_size(p, member, count))
 
+static inline __must_check size_t __ab_c_size(size_t a, size_t b, size_t c)
+{
+	size_t bytes;
+
+	if (check_mul_overflow(a, b, &bytes))
+		return SIZE_MAX;
+	if (check_add_overflow(bytes, c, &bytes))
+		return SIZE_MAX;
+
+	return bytes;
+}
 #endif /* __LINUX_OVERFLOW_H */
-- 
2.35.3