oops on unload during irq monitoring.
mjsir911 opened this issue · 1 comments
mjsir911 commented
To reproduce:
- load drivers
gpiomon --rising-edge /dev/gpiochipN 10
- unload drivers (specifically
gpio_ch341
)
[ 7366.300590] ------------[ cut here ]------------
[ 7366.300591] remove_proc_entry: removing non-empty directory 'irq/206', leaking at least 'gpiomon'
[ 7366.300597] WARNING: CPU: 2 PID: 23863 at fs/proc/generic.c:717 remove_proc_entry+0x19c/0x1c0
[ 7366.300602] Modules linked in: spi_ch341(O) i2c_ch341(O) gpio_ch341(O) ch341_core(O-) rfcomm uas qrtr bnep usb_storage uvcvideo videobuf2_vmalloc videobuf2_memops uvc btusb videobuf2_v4l2 btrtl btintel videodev btbcm btmtk videobuf2_common mc bluetooth hid_sensor_als hid_sensor_trigger industrialio_triggered_buffer hid_sensor_iio_common kfifo_buf industrialio hid_sensor_hub intel_ishtp_hid vfat fat snd_hda_codec_hdmi snd_sof_pci_intel_tgl snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_sof_utils snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core iwlmvm intel_powerclamp snd_compress snd_hda_codec_idt cros_usbpd_charger snd_sof_intel_hda_mlink snd_hda_codec_generic cros_ec_sysfs coretemp cros_ec_chardev cros_usbpd_logger cros_usbpd_notify snd_hda_ext_core ofpart mac80211 snd_hda_intel snd_intel_dspcfg kvm_intel spi_nor iTCO_wdt snd_hda_codec cros_ec_dev joydev mei_hdcp mei_pxp mtd mei_wdt ee1004 libarc4 hid_multitouch iTCO_vendor_support cros_ec_lpcs snd_hwdep
[ 7366.300634] cros_ec kvm snd_hda_core irqbypass crct10dif_pclmul iwlwifi polyval_clmulni snd_pcm polyval_generic snd_timer ghash_clmulni_intel cfg80211 mei_me i2c_i801 snd intel_ish_ipc sha512_ssse3 ucsi_acpi spi_intel_pci binfmt_misc sha256_ssse3 sha1_ssse3 rapl intel_cstate intel_uncore serio_raw pcspkr intel_rapl_msr typec_ucsi spi_intel rfkill wmi_bmof soundcore i2c_smbus intel_ishtp mei idma64 thunderbolt typec igen6_edac i2c_hid_acpi intel_pmc_core i2c_hid pinctrl_tigerlake intel_vsec pinctrl_intel pmt_telemetry pwm_lpss pmt_class acpi_pad xhci_pci xhci_pci_renesas xhci_hcd crc32_pclmul crc32c_intel usbcore usb_common
[ 7366.300655] Unloaded tainted modules: i2c_ch341(O):32 spi_ch341(O):31 gpio_ch341(O):30 ch341_core(O):32 [last unloaded: i2c_ch341(O)]
[ 7366.300659] CPU: 2 PID: 23863 Comm: rmmod Kdump: loaded Tainted: G R W O 6.8.0-rc4-devel+ #26
[ 7366.300660] Hardware name: Framework Laptop/FRANBMCP0C, BIOS 03.17 10/27/2022
[ 7366.300661] RIP: 0010:remove_proc_entry+0x19c/0x1c0
[ 7366.300663] Code: c7 58 d4 dc 82 48 85 c0 48 8d 90 78 ff ff ff 48 0f 45 c2 48 8b 53 f0 4c 8b 80 a0 00 00 00 48 8b 92 a0 00 00 00 e8 c4 cc be ff <0f> 0b e9 76 ff ff ff 48 8b 73 18 48 c7 c7 30 d4 dc 82 e8 ad cc be
[ 7366.300664] RSP: 0018:ffffc90000e03a60 EFLAGS: 00010282
[ 7366.300666] RAX: 0000000000000000 RBX: ffff8881e12b6ec8 RCX: 0000000000000027
[ 7366.300667] RDX: ffff88888fa9da08 RSI: 0000000000000001 RDI: ffff88888fa9da00
[ 7366.300667] RBP: ffff8881e12b6e40 R08: 0000000000000000 R09: ffffc90000e038e8
[ 7366.300668] R10: 0000000000000003 R11: ffffffff83126d18 R12: ffff8881e12b6ec0
[ 7366.300669] R13: ffffc90000e03ab6 R14: ffffc90000e03ab6 R15: ffff8881002e86c0
[ 7366.300669] FS: 00007f88ca20bc40(0000) GS:ffff88888fa80000(0000) knlGS:0000000000000000
[ 7366.300670] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 7366.300671] CR2: 000056172b9b8848 CR3: 00000001d93f6002 CR4: 0000000000f70ef0
[ 7366.300672] PKRU: 55555554
[ 7366.300673] Call Trace:
[ 7366.300674] <TASK>
[ 7366.300675] ? remove_proc_entry+0x19c/0x1c0
[ 7366.300677] ? __warn+0x81/0x130
[ 7366.300680] ? remove_proc_entry+0x19c/0x1c0
[ 7366.300682] ? report_bug+0x171/0x1a0
[ 7366.300684] ? console_unlock+0x78/0x120
[ 7366.300686] ? handle_bug+0x3c/0x80
[ 7366.300688] ? exc_invalid_op+0x17/0x70
[ 7366.300689] ? asm_exc_invalid_op+0x1a/0x20
[ 7366.300692] ? remove_proc_entry+0x19c/0x1c0
[ 7366.300694] unregister_irq_proc+0xf4/0x120
[ 7366.300696] free_desc+0x3d/0xe0
[ 7366.300698] ? __irq_get_desc_lock+0x55/0x90
[ 7366.300700] ? __irq_put_desc_unlock+0x1c/0x50
[ 7366.300701] ? irq_set_chip_data+0x4c/0x80
[ 7366.300703] irq_free_descs+0x47/0x70
[ 7366.300706] gpiochip_irqchip_remove+0xdf/0x210
[ 7366.300709] gpiochip_remove+0x3e/0x150
[ 7366.300710] ch341_gpio_remove+0x22/0x40 [gpio_ch341]
[ 7366.300714] platform_remove+0x3c/0x60
[ 7366.300716] device_release_driver_internal+0x19f/0x200
[ 7366.300719] bus_remove_device+0xc6/0x130
[ 7366.300720] device_del+0x15c/0x3f0
[ 7366.300722] ? kfree+0x29f/0x2f0
[ 7366.300725] platform_device_del.part.0+0x13/0x70
[ 7366.300726] platform_device_unregister+0x20/0x40
[ 7366.300728] mfd_remove_devices_fn+0xd4/0xf0
[ 7366.300730] ? __pfx_mfd_remove_devices_fn+0x10/0x10
[ 7366.300732] device_for_each_child_reverse+0x6e/0xb0
[ 7366.300734] devm_mfd_dev_release+0x36/0x60
[ 7366.300735] release_nodes+0x3d/0xb0
[ 7366.300738] devres_release_all+0x8c/0xc0
[ 7366.300739] device_unbind_cleanup+0xe/0x70
[ 7366.300741] device_release_driver_internal+0x1c4/0x200
[ 7366.300743] driver_detach+0x48/0x90
[ 7366.300744] bus_remove_driver+0x6d/0xf0
[ 7366.300746] usb_deregister+0x76/0xd0 [usbcore]
[ 7366.300768] __do_sys_delete_module+0x1d2/0x320
[ 7366.300770] do_syscall_64+0x86/0x1a0
[ 7366.300773] ? syscall_exit_to_user_mode+0x89/0x230
[ 7366.300775] ? do_syscall_64+0x95/0x1a0
[ 7366.300777] ? exc_page_fault+0x7f/0x180
[ 7366.300779] entry_SYSCALL_64_after_hwframe+0x6e/0x76
[ 7366.300781] RIP: 0033:0x7f88ca303997
[ 7366.300783] Code: 73 01 c3 48 8b 0d 91 b4 0a 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 61 b4 0a 00 f7 d8 64 89 01 48
[ 7366.300783] RSP: 002b:00007fff3e963f68 EFLAGS: 00000202 ORIG_RAX: 00000000000000b0
[ 7366.300785] RAX: ffffffffffffffda RBX: 000056172b9ae700 RCX: 00007f88ca303997
[ 7366.300785] RDX: 000000000000000a RSI: 0000000000000800 RDI: 000056172b9ae768
[ 7366.300786] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
[ 7366.300787] R10: 0000000000000000 R11: 0000000000000202 R12: 00007fff3e9641b0
[ 7366.300787] R13: 00007fff3e96567b R14: 000056172b9ae2a0 R15: 000056172b9ae700
[ 7366.300788] </TASK>
[ 7366.300789] ---[ end trace 0000000000000000 ]---
[ 7366.300795] gpio gpiochip12: REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED
[ 7366.300932] ------------[ cut here ]------------
[ 7366.300934] WARNING: CPU: 3 PID: 23849 at drivers/gpio/gpiolib.c:2352 gpiod_free+0x1b/0x40
[ 7366.300938] Modules linked in: spi_ch341(O) i2c_ch341(O) gpio_ch341(O) ch341_core(O-) rfcomm uas qrtr bnep usb_storage uvcvideo videobuf2_vmalloc videobuf2_memops uvc btusb videobuf2_v4l2 btrtl btintel videodev btbcm btmtk videobuf2_common mc bluetooth hid_sensor_als hid_sensor_trigger industrialio_triggered_buffer hid_sensor_iio_common kfifo_buf industrialio hid_sensor_hub intel_ishtp_hid vfat fat snd_hda_codec_hdmi snd_sof_pci_intel_tgl snd_sof_intel_hda_common snd_soc_hdac_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_sof_utils snd_soc_acpi_intel_match snd_soc_acpi snd_soc_core iwlmvm intel_powerclamp snd_compress snd_hda_codec_idt cros_usbpd_charger snd_sof_intel_hda_mlink snd_hda_codec_generic cros_ec_sysfs coretemp cros_ec_chardev cros_usbpd_logger cros_usbpd_notify snd_hda_ext_core ofpart mac80211 snd_hda_intel snd_intel_dspcfg kvm_intel spi_nor iTCO_wdt snd_hda_codec cros_ec_dev joydev mei_hdcp mei_pxp mtd mei_wdt ee1004 libarc4 hid_multitouch iTCO_vendor_support cros_ec_lpcs snd_hwdep
[ 7366.300964] cros_ec kvm snd_hda_core irqbypass crct10dif_pclmul iwlwifi polyval_clmulni snd_pcm polyval_generic snd_timer ghash_clmulni_intel cfg80211 mei_me i2c_i801 snd intel_ish_ipc sha512_ssse3 ucsi_acpi spi_intel_pci binfmt_misc sha256_ssse3 sha1_ssse3 rapl intel_cstate intel_uncore serio_raw pcspkr intel_rapl_msr typec_ucsi spi_intel rfkill wmi_bmof soundcore i2c_smbus intel_ishtp mei idma64 thunderbolt typec igen6_edac i2c_hid_acpi intel_pmc_core i2c_hid pinctrl_tigerlake intel_vsec pinctrl_intel pmt_telemetry pwm_lpss pmt_class acpi_pad xhci_pci xhci_pci_renesas xhci_hcd crc32_pclmul crc32c_intel usbcore usb_common
[ 7366.300980] Unloaded tainted modules: i2c_ch341(O):32 spi_ch341(O):31 gpio_ch341(O):30 ch341_core(O):32 [last unloaded: i2c_ch341(O)]
[ 7366.300983] CPU: 3 PID: 23849 Comm: gpiomon Kdump: loaded Tainted: G R W O 6.8.0-rc4-devel+ #26
[ 7366.300986] Hardware name: Framework Laptop/FRANBMCP0C, BIOS 03.17 10/27/2022
[ 7366.300986] RIP: 0010:gpiod_free+0x1b/0x40
[ 7366.300988] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00 48 85 ff 74 27 53 48 89 fb e8 f9 d2 ff ff 84 c0 75 02 <0f> 0b 48 8b 03 48 8b b8 68 03 00 00 e8 34 d8 7e ff 48 8b 3b 5b e9
[ 7366.300989] RSP: 0018:ffffc90000aabdb8 EFLAGS: 00010246
[ 7366.300990] RAX: 0000000000000000 RBX: ffff8882643f3990 RCX: ffff888104624900
[ 7366.300991] RDX: 0000000000000000 RSI: 0000000000000002 RDI: ffff8881aa9933a8
[ 7366.300992] RBP: 00000000000a0005 R08: 0000000000000000 R09: 0000000000000000
[ 7366.300992] R10: 0000000000000000 R11: 0000000000000001 R12: ffff8881005b6300
[ 7366.300993] R13: ffff88810155f520 R14: ffff8882f3862b40 R15: 0000000000000000
[ 7366.300994] FS: 00007f5a4a584740(0000) GS:ffff88888fac0000(0000) knlGS:0000000000000000
[ 7366.300995] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 7366.300996] CR2: 000034c59af5e000 CR3: 00000001043fe004 CR4: 0000000000f70ef0
[ 7366.300997] PKRU: 55555554
[ 7366.300997] Call Trace:
[ 7366.300998] <TASK>
[ 7366.300998] ? gpiod_free+0x1b/0x40
[ 7366.301000] ? __warn+0x81/0x130
[ 7366.301002] ? gpiod_free+0x1b/0x40
[ 7366.301003] ? report_bug+0x171/0x1a0
[ 7366.301006] ? handle_bug+0x3c/0x80
[ 7366.301007] ? exc_invalid_op+0x17/0x70
[ 7366.301008] ? asm_exc_invalid_op+0x1a/0x20
[ 7366.301011] ? gpiod_free+0x1b/0x40
[ 7366.301012] ? gpiod_free+0x17/0x40
[ 7366.301014] lineevent_free+0x38/0x60
[ 7366.301015] lineevent_release+0x15/0x20
[ 7366.301016] __fput+0x97/0x2c0
[ 7366.301019] __x64_sys_close+0x3d/0x80
[ 7366.301022] do_syscall_64+0x86/0x1a0
[ 7366.301025] ? ksys_read+0x6f/0xf0
[ 7366.301026] ? syscall_exit_to_user_mode+0x89/0x230
[ 7366.301028] ? do_syscall_64+0x95/0x1a0
[ 7366.301029] ? do_syscall_64+0x95/0x1a0
[ 7366.301031] ? do_syscall_64+0x95/0x1a0
[ 7366.301032] ? syscall_exit_to_user_mode+0x89/0x230
[ 7366.301034] ? do_syscall_64+0x95/0x1a0
[ 7366.301035] ? exc_page_fault+0x7f/0x180
[ 7366.301037] entry_SYSCALL_64_after_hwframe+0x6e/0x76
[ 7366.301039] RIP: 0033:0x7f5a4a66d2e0
[ 7366.301041] Code: 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 80 3d 89 40 0c 00 00 74 17 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c
[ 7366.301041] RSP: 002b:00007ffca843cd48 EFLAGS: 00000202 ORIG_RAX: 0000000000000003
[ 7366.301043] RAX: ffffffffffffffda RBX: 00007ffca843cd80 RCX: 00007f5a4a66d2e0
[ 7366.301043] RDX: 0000000000000001 RSI: 00007ffca843ce70 RDI: 0000000000000005
[ 7366.301044] RBP: 0000558276b46500 R08: 0000558276b46570 R09: 00007f5a4a729b20
[ 7366.301044] R10: 0000000000000000 R11: 0000000000000202 R12: 00007ffca843cd80
[ 7366.301045] R13: 0000558276b462a0 R14: 00007ffca843d054 R15: 0000000000000001
[ 7366.301046] </TASK>
[ 7366.301047] ---[ end trace 0000000000000000 ]---
frank-zago commented
Yes, I'm aware of that one. I mentioned it in the README:
Warning: try not to yank the USB device out if it's being used. The
linux subsystems gpio and spi may crash or leak resources. This is not
a problem with the drivers, but the subsystems themselves.
I can reproduce with the gpio mockup driver like this:
(under qemu)
modprobe gpio-mockup gpio_mockup_ranges=-1,8
gpioinfo
gpiomon 0 1 &
echo gpio-mockup.0 > /sys/bus/platform/drivers/gpio-mockup/unbind