Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
[linux-2.6-microblaze.git] / lib / ubsan.c
index bec38c6..bdc380f 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
+#include <kunit/test-bug.h>
 
 #include "ubsan.h"
 
@@ -141,6 +142,8 @@ static void ubsan_prologue(struct source_location *loc, const char *reason)
                "========================================\n");
        pr_err("UBSAN: %s in %s:%d:%d\n", reason, loc->file_name,
                loc->line & LINE_MASK, loc->column & COLUMN_MASK);
+
+       kunit_fail_current_test("%s in %s", reason, loc->file_name);
 }
 
 static void ubsan_epilogue(void)
@@ -163,74 +166,6 @@ static void ubsan_epilogue(void)
        }
 }
 
-static void handle_overflow(struct overflow_data *data, void *lhs,
-                       void *rhs, char op)
-{
-
-       struct type_descriptor *type = data->type;
-       char lhs_val_str[VALUE_LENGTH];
-       char rhs_val_str[VALUE_LENGTH];
-
-       if (suppress_report(&data->location))
-               return;
-
-       ubsan_prologue(&data->location, type_is_signed(type) ?
-                       "signed-integer-overflow" :
-                       "unsigned-integer-overflow");
-
-       val_to_string(lhs_val_str, sizeof(lhs_val_str), type, lhs);
-       val_to_string(rhs_val_str, sizeof(rhs_val_str), type, rhs);
-       pr_err("%s %c %s cannot be represented in type %s\n",
-               lhs_val_str,
-               op,
-               rhs_val_str,
-               type->type_name);
-
-       ubsan_epilogue();
-}
-
-void __ubsan_handle_add_overflow(void *data,
-                               void *lhs, void *rhs)
-{
-
-       handle_overflow(data, lhs, rhs, '+');
-}
-EXPORT_SYMBOL(__ubsan_handle_add_overflow);
-
-void __ubsan_handle_sub_overflow(void *data,
-                               void *lhs, void *rhs)
-{
-       handle_overflow(data, lhs, rhs, '-');
-}
-EXPORT_SYMBOL(__ubsan_handle_sub_overflow);
-
-void __ubsan_handle_mul_overflow(void *data,
-                               void *lhs, void *rhs)
-{
-       handle_overflow(data, lhs, rhs, '*');
-}
-EXPORT_SYMBOL(__ubsan_handle_mul_overflow);
-
-void __ubsan_handle_negate_overflow(void *_data, void *old_val)
-{
-       struct overflow_data *data = _data;
-       char old_val_str[VALUE_LENGTH];
-
-       if (suppress_report(&data->location))
-               return;
-
-       ubsan_prologue(&data->location, "negation-overflow");
-
-       val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val);
-
-       pr_err("negation of %s cannot be represented in type %s:\n",
-               old_val_str, data->type->type_name);
-
-       ubsan_epilogue();
-}
-EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
-
-
 void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
 {
        struct overflow_data *data = _data;