@@ -369,7 +369,7 @@ LDFLAGS_MODULE =
CFLAGS_KERNEL =
AFLAGS_KERNEL =
CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im -Wno-maybe-uninitialized
-CFLAGS_KCOV = -fsanitize-coverage=trace-pc
+CFLAGS_KCOV = -fsanitize-coverage=trace-pc -DCONFIG_KCOV_CC
# Use USERINCLUDE when you must reference the UAPI directories only.
@@ -3,6 +3,7 @@
#define DISABLE_BRANCH_PROFILING
#include <linux/compiler.h>
#include <linux/types.h>
+#include <linux/errno.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/mm.h>
@@ -160,6 +161,13 @@ static int kcov_open(struct inode *inode, struct file *filep)
{
struct kcov *kcov;
+ /*
+ * CONFIG_KCOV was selected, but the compiler does not support the
+ * options KCOV requires.
+ */
+ if (!IS_ENABLED(CONFIG_KCOV_CC))
+ return -ENOTSUPP;
+
kcov = kzalloc(sizeof(*kcov), GFP_KERNEL);
if (!kcov)
return -ENOMEM;