return *counter;
 }
+
+/* Don't allow the compiler to inline the calls. */
+static noinline void lkdtm_indirect_call(void (*func)(int *))
+{
+       func(&called_count);
+}
+
 /*
  * This tries to call an indirect function with a mismatched prototype.
  */
         * Matches lkdtm_increment_void()'s prototype, but not
         * lkdtm_increment_int()'s prototype.
         */
-       void (*func)(int *);
-
        pr_info("Calling matched prototype ...\n");
-       func = lkdtm_increment_void;
-       func(&called_count);
+       lkdtm_indirect_call(lkdtm_increment_void);
 
        pr_info("Calling mismatched prototype ...\n");
-       func = (void *)lkdtm_increment_int;
-       func(&called_count);
+       lkdtm_indirect_call((void *)lkdtm_increment_int);
 
        pr_err("FAIL: survived mismatched prototype function call!\n");
        pr_expected_config(CONFIG_CFI_CLANG);