Skip to content

Instantly share code, notes, and snippets.

@gautammenghani
Last active February 9, 2022 06:40
Show Gist options
  • Select an option

  • Save gautammenghani/cb2e7c8ab4cbc39a43fcb84f843705ed to your computer and use it in GitHub Desktop.

Select an option

Save gautammenghani/cb2e7c8ab4cbc39a43fcb84f843705ed to your computer and use it in GitHub Desktop.

oops.c

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

MODULE_LICENSE("GPL"); static int test_panic_init(void) { printk(KERN_INFO"%s: In init\n", func); panic("Hello Kernel I am causing the panic\n"); return 0; }

static void test_panic_exit(void) { printk(KERN_INFO"%s: In exit\n", func); }

module_init(test_panic_init); module_exit(test_panic_exit);

Makefile

obj-m := oops.o KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) SYM=$(PWD)

all: $(MAKE) -C $(KDIR) M=`pwd` SUBDIRS=$(PWD) modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment