[RFC PATCH 1/3] arc: use BUILD_BUG for invalid sizes in get_user/put_user

Sergey Matyukevich geomatsi at gmail.com
Tue Feb 1 06:55:36 PST 2022


From: Sergey Matyukevich <sergey.matyukevich at synopsys.com>

Use BUILD_BUG for compile-time check of invalid sizes passed
to get_user/put_user functions.

Signed-off-by: Sergey Matyukevich <sergey.matyukevich at synopsys.com>
---
 arch/arc/include/asm/uaccess.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index 783bfdb3bfa3..9d1205bf90f1 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -62,6 +62,7 @@
 	case 2: __arc_get_user_one(*(k), u, "ldw", __ret); break;	\
 	case 4: __arc_get_user_one(*(k), u, "ld", __ret);  break;	\
 	case 8: __arc_get_user_one_64(*(k), u, __ret);     break;	\
+	default: BUILD_BUG();                                   \
 	}							\
 	__ret;							\
 })
@@ -123,6 +124,7 @@
 	case 2: __arc_put_user_one(*(k), u, "stw", __ret); break;	\
 	case 4: __arc_put_user_one(*(k), u, "st", __ret);  break;	\
 	case 8: __arc_put_user_one_64(*(k), u, __ret);     break;	\
+	default: BUILD_BUG();                                   \
 	}							\
 	__ret;							\
 })
-- 
2.35.0




More information about the linux-snps-arc mailing list