Skip to content

Commit

Permalink
fix(driver): use configure system to build class_create with a single…
Browse files Browse the repository at this point in the history
… parameter

Address RHEL 9 backport of class_create signature change introduced in kernel 6.4
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1aaba11da9aa7d7d6b52a74d45b31cac118295a1

Signed-off-by: Angelo Puglisi <[email protected]>
  • Loading branch information
deepskyblue86 authored and poiana committed Mar 5, 2024
1 parent 151b277 commit 9f75998
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions driver/configure/CLASS_CREATE_1/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2024 The Falco Authors.
This file is dual licensed under either the MIT or GPL 2. See MIT.txt
or GPL2.txt for full copies of the license.
*/

/*
* Check that `class_create` builds with only a single parameter
* See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=1aaba11da9aa7d7d6b52a74d45b31cac118295a1
*/

#include <linux/module.h>
#include <linux/device.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("the Falco authors");

static int class_create_test_init(void)
{
struct class *g_ppm_class = class_create("test");
return 0;
}

static void class_create_test_exit(void)
{
}

module_init(class_create_test_init);
module_exit(class_create_test_exit);
2 changes: 1 addition & 1 deletion driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2864,7 +2864,7 @@ int scap_init(void)
goto init_module_err;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
#ifndef HAS_CLASS_CREATE_1
g_ppm_class = class_create(THIS_MODULE, DRIVER_DEVICE_NAME);
#else
g_ppm_class = class_create(DRIVER_DEVICE_NAME);
Expand Down

0 comments on commit 9f75998

Please sign in to comment.