title: Crash system when the module is running
body: <p>I need to write a module that creates a file and outputs an inscription with a certain frequency. I implemented it. But when this module is running, at some point the system crashes and no longer turns on.</p>
  <pre><code>#include &lt;linux/module.h&gt;
  #include &lt;linux/init.h&gt;
  #include &lt;linux/fs.h&gt;
  #include &lt;linux/uaccess.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/timer.h&gt;
  
  MODULE_LICENSE(&quot;GPL&quot;);
  
  #define BUF_LEN 255
  #define TEXT &quot;Hello from kernel mod\n&quot;
  
  int g_timer_interval = 10000;
  
  static struct file *i_fp;
  struct timer_list g_timer;
  
  loff_t offset = 0;
  char buff[BUF_LEN + 1] = TEXT;
  
  void timer_rest(struct timer_list *timer)
  
  {
      mod_timer(&amp;g_timer, jiffies + msecs_to_jiffies(g_timer_interval));
      i_fp = filp_open(&quot;/home/hajol/Test.txt&quot;, O_RDWR | O_CREAT, 0644);
      kernel_write(i_fp, buff, strlen(buff), &amp;offset);
      filp_close(i_fp, NULL);
  }
    
  static int __init kernel_init(void)
  {
      timer_setup(&amp;g_timer, timer_rest, 0);
      mod_timer(&amp;g_timer, jiffies + msecs_to_jiffies(g_timer_interval));
      return 0;
  }
  
  static void __exit kernel_exit(void)
  {
      pr_info(&quot;Ending&quot;);
      del_timer(&amp;g_timer);
  }
  
  module_init(kernel_init);
  module_exit(kernel_exit);
  </code></pre>