Home > OS >  When each rmmod driver kernel crash, the great god see code have what problem
When each rmmod driver kernel crash, the great god see code have what problem

Time:11-13

Char_device. C
 # include & lt; Linux/init. H> 
#include
#include

Struct platform_device chardev={
.name="chrdevbase",
Id=1,
};

Static int char_device_init (void) {

Printk (" char device init \ n ");
Return platform_device_register (& amp; Chardev);
}

The static void char_device_exit (void) {
Printk (" char device exit \ n ");
}

MODULE_LICENSE (" GPL ");
The module_init (char_device_init);
Module_exit (char_device_exit);


Char_driver. C
 # include & lt; Linux/init. H> 
#include
#include

Int char_dev_probe (struct platform_device * dev) {
Printk (" platform driver probe \ n ");
return 0;
}

Int char_dev_remove (struct platform_device * dev) {
Printk (" platform driver remove \ n ");
return 0;
}

Struct platform_driver chardri={
The driver={
The owner=THIS_MODULE,
.name="chrdevbase",
},
The probe=char_dev_probe,
Remove=char_dev_remove,
};

Static int char_driver_init (void) {

Printk (" platform driver init \ n ");
Return platform_driver_register (& amp; Chardri);
}

The static void char_driver_exit (void) {
Platform_driver_unregister (& amp; Chardri);
Printk (" platform driver exit \ n ");
}

MODULE_LICENSE (" GPL ");
The module_init (char_driver_init);
Module_exit (char_driver_exit);


The makefile:
 
Obj - m:=char_device. O char_driver. O

KDIR:=/lib/modules/$(shell uname -r)/build
The PWD:=$(shell PWD)
All:
$(MAKE) - C $(KDIR) M=$(PWD) modules
Clean:
The rm -f *. Ko * o *. Symvers *. CMD *. CMD. O



Dmesg:
 [2380.724760] char device init 
[2390.660401] platform driver init
[2390.660422] platform driver probe
[2421.906509] platform driver remove
[2421.906534] -- -- -- -- -- -- -- -- -- -- -- -- [the cut here] -- -- -- -- -- -- -- -- -- -- -- --
[2421.906534] Device 'chrdevbase' does not have a release () function, it is broken and must be fixed.
[2421.906545] WARNING: CPU: PID: 1 4594 at/build/Linux - CbANGF/Linux - 4.15.0/drivers/base/core. C: 895 x90 device_release + 0 x80/0
[ 2421.906545] Modules linked in: char_driver(OE) char_device(OE-) ip6table_filter ip6_tables iptable_filter pci_stub vboxpci(OE) vboxnetadp(OE) vboxnetflt(OE) vboxdrv(OE) ccm nls_iso8859_1 snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp snd_pcm kvm_intel 8250_dw snd_seq_midi snd_seq_midi_event snd_rawmidi kvm arc4 mxm_wmi irqbypass snd_seq crct10dif_pclmul crc32_pclmul snd_seq_device ghash_clmulni_intel snd_timer iwldvm pcbc mac80211 aesni_intel aes_x86_64 crypto_simd glue_helper cryptd iwlwifi intel_cstate snd intel_rapl_perf cfg80211 serio_raw shpchp soundcore input_leds i915 joydev mei_me mei drm_kms_helper idma64 virt_dma intel_pch_thermal drm i2c_algo_bit intel_lpss_pci fb_sys_fops
[2421.906589] syscopyarea sysfillrect intel_lpss sysimgblt mac_hid wmi video acpi_pad sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 hid_generic usbhid hid ahci psmouse libahci r8169 mii pinctrl_sunrisepoint
[2421.906597] CPU: 1 PID: 4594 Comm: rmmod Tainted: OE 4.15.0-99 - G generic # 100 - Ubuntu
[2421.906597] Hardware name: MSI/B150M PRO - MS - 7996 VH (MS - 7996), the BIOS 1.80 07/27/2016
[2421.906599] RIP: 0010: device_release + 0 x80/0 x90
[2421.906600] RSP: 0018: ffffbdb400ddbe30 EFLAGS: 00010282
[2421.906601] RAX: 0000000000000000 RBX: ffffffffc0a7c020 RCX: 0000000000000006
[2421.906601] RDX: 0000000000000007, 0000000000000092: RSI RDI: ffff9dd3eec96490
[2421.906602] RBP: ffffbdb400ddbe48 R08, R09 000000000000035 b: 0000000000000004
[2421.906602] R10: fffff8cf87518e00 R11: ffffffff8755c80d R12: ffffffffc0a7c010
[2421.906603] R13: ffff9dd3df52ff00 R14: ffff9dd3d2353ae0 R15:0000000000000000
F222dc87540 [2421.906604] FS - 00007 (0000) GS: ffff9dd3eec80000 knlGS (0000) : 0000000000000000
CS: [2421.906604] 0010 DS: 0000 ES: 0000 CR0:0000000080050033
[2421.906605] CR2:0000563 fea1e3f08 CR3, : 0000000181 d14005 CR4:00000000003606 e0
[2421.906605] Call Trace:
[2421.906610] kobject_release + 0 x6a/0 x180
[2421.906611] kobject_put + 0 x28/0 x50
[2421.906612] put_device + 0 x17/0 x20
[2421.906614] platform_device_unregister + 0 x20/0 x30
[2421.906628] char_device_exit + 0 x15/0 xfd0 [char_device]
[2421.906630] SyS_delete_module + 0 x1ab/0 x2d0
[2421.906632] do_syscall_64 + 0 x73/0 x130
[2421.906634] entry_SYSCALL_64_after_hwframe + 0 x3d/0 xa2
[2421.906635] RIP: 0033:0 x7f222d7ab1b7
[2421.906636] RSP: 002 b: 00007 fff171fbb48 EFLAGS: 00000206 ORIG_RAX: 00000000000000 b0
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related