2 Commits

Author SHA1 Message Date
eb6167ae63 add uncaught bug for debugging in the wild 2024-12-17 20:56:26 +02:00
ace684facc hotfix: checkpatch-related issues 2024-12-01 20:49:22 +02:00
4 changed files with 21 additions and 11 deletions

View File

@@ -2,13 +2,17 @@
ifneq ($(KERNELRELEASE),)
# kbuild part of makefile
obj-m := hello1.o hello2.o
ccflags-y := -I$(obj)/inc
ccflags-y := -I$(obj)/inc -g
else
# normal makefile
KDIR ?= /lib/modules/`uname -r`/build
default:
$(MAKE) -C $(KDIR) M=$$PWD
cp hello1.ko hello1.ko.unstripped
$(CROSS_COMPILE)strip -g hello1.ko
clean:
$(MAKE) -C $(KDIR) M=$$PWD clean
endif

View File

@@ -45,6 +45,7 @@ struct TimingList {
};
static struct TimingList *tl_head;
static unsigned int bug_generator;
static struct TimingList *write_first_node(void)
{
@@ -59,8 +60,12 @@ static struct TimingList* insert_next_node(struct TimingList *tail)
struct TimingList *new_tl_node = kmalloc(sizeof(struct TimingList),
GFP_KERNEL);
if (bug_generator == 2) {
new_tl_node = NULL;
} else {
tail->next = new_tl_node;
new_tl_node->next = NULL;
}
return new_tl_node;
}
@@ -93,6 +98,7 @@ void destroy_list(void)
curr_tl = next_tl;
}
}
EXPORT_SYMBOL(destroy_list);
static int __init hello_init(void)
{
@@ -105,6 +111,8 @@ void print_hello(int msg_count)
struct TimingList *current_tail = tl_head;
for (i = 0; i < msg_count; i++) {
bug_generator = i;
current_tail = add_new_node(current_tail);
current_tail->t_before = ktime_get();
@@ -112,14 +120,13 @@ void print_hello(int msg_count)
current_tail->t_after = ktime_get();
}
}
EXPORT_SYMBOL(print_hello);
static void __exit hello_exit(void)
{
destroy_list();
}
EXPORT_SYMBOL(print_hello);
EXPORT_SYMBOL(destroy_list);
module_init(hello_init);
module_exit(hello_exit);

View File

@@ -49,9 +49,8 @@ static int __init hello_init(void)
return -EINVAL;
}
if (msg_count == 0 || msg_count >= 5) {
if (msg_count == 0 || msg_count >= 5)
pr_warn("Warning: msg_count = %d (msg_count == 0 or 5 <= msg_count <= 10)\n", msg_count);
}
print_hello(msg_count);
return 0;

View File

@@ -1,2 +1,2 @@
void print_hello(int);
void print_hello(int msg_count);
void destroy_list(void);