RicardoEPRodrigues / magicmouse-hid

Magic Mouse 2 driver for Linux.
148 stars 17 forks source link

Crash when Magic Trackpad Disconnects #18

Open sduensin opened 6 months ago

sduensin commented 6 months ago

If I unplug my Magic Trackpad from USB or turn it off, I get the following crash:

│[17366.439139] usb 5-2.3: USB disconnect, device number 8                                                                                                                                                                                   │
│[17366.501181] BUG: kernel NULL pointer dereference, address: 0000000000000170                                                                                                                                                              │
│[17366.501184] #PF: supervisor read access in kernel mode                                                                                                                                                                                   │
│[17366.501186] #PF: error_code(0x0000) - not-present page                                                                                                                                                                                   │
│[17366.501187] PGD 0 P4D 0                                                                                                                                                                                                                  │
│[17366.501190] Oops: 0000 [#1] PREEMPT SMP NOPTI                                                                                                                                                                                            │
│[17366.501192] CPU: 10 PID: 139201 Comm: kworker/10:0 Tainted: P           OE      6.5.0-28-generic #29~22.04.1-Ubuntu                                                                                                                      │
│[17366.501195] Hardware name: Gigabyte Technology Co., Ltd. B650I AORUS ULTRA/B650I AORUS ULTRA, BIOS F8 07/10/2023                                                                                                                         │
│[17366.501196] Workqueue: usb_hub_wq hub_event                                                                                                                                                                                              │
│[17366.501201] RIP: 0010:timer_delete+0x2c/0x90                                                                                                                                                                                             │
│[17366.501205] Code: 44 00 00 55 48 89 e5 41 55 41 54 45 31 e4 53 48 83 ec 10 65 48 8b 04 25 28 00 00 00 48 89 45 e0 31 c0 48 c7 45 d8 00 00 00 00 <48> 8b 47 08 48 85 c0 74 2e 48 8d 75 d8 48 89 fb e8 cf db ff ff 48                      │
│[17366.501207] RSP: 0018:ffffad1a97e7f828 EFLAGS: 00010046                                                                                                                                                                                  │
│[17366.501209] RAX: 0000000000000000 RBX: 0000000000000148 RCX: 0000000000000000                                                                                                                                                            │
│[17366.501210] RDX: ffffad1a97e7f890 RSI: 0000000000000001 RDI: 0000000000000168                                                                                                                                                            │
│[17366.501211] RBP: ffffad1a97e7f850 R08: 0000000000000001 R09: 0000000000000286                                                                                                                                                            │
│[17366.501212] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000                                                                                                                                                            │
│[17366.501213] R13: 0000000000000001 R14: ffff8a32e2c2d950 R15: 0000000000000080                                                                                                                                                            │
│[17366.501215] FS:  0000000000000000(0000) GS:ffff8a39f8880000(0000) knlGS:0000000000000000                                                                                                                                                 │
│[17366.501216] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033                                                                                                                                                                            │
│[17366.501217] CR2: 0000000000000170 CR3: 000000054c83a000 CR4: 0000000000750ee0                                                                                                                                                            │
│[17366.501219] PKRU: 55555554                                                                                                                                                                                                               │
│[17366.501220] Call Trace:                                                                                                                                                                                                                  │
│[17366.501222]  <TASK>                                                                                                                                                                                                                      │
│[17366.501225]  ? show_regs+0x6d/0x80                                                                                                                                                                                                       │
│[17366.501229]  ? __die+0x24/0x80                                                                                                                                                                                                           │
│[17366.501231]  ? page_fault_oops+0x99/0x1b0                                                                                                                                                                                                │
│[17366.501235]  ? do_user_addr_fault+0x31d/0x6b0                                                                                                                                                                                            │
│[17366.501237]  ? exc_page_fault+0x83/0x1b0                                                                                                                                                                                                 │
│[17366.501240]  ? asm_exc_page_fault+0x27/0x30                                                                                                                                                                                              │
│[17366.501245]  ? timer_delete+0x2c/0x90                                                                                                                                                                                                    │
│[17366.501248]  try_to_grab_pending+0x109/0x1a0                                                                                                                                                                                             │
│[17366.501251]  __cancel_work_timer+0x3f/0x1b0                                                                                                                                                                                              │
│[17366.501253]  ? srso_alias_return_thunk+0x5/0x7f                                                                                                                                                                                          │
│[17366.501255]  ? kernfs_name_hash+0x17/0x90                                                                                                                                                                                                │
│[17366.501259]  ? srso_alias_return_thunk+0x5/0x7f                                                                                                                                                                                          │
│[17366.501260]  ? kernfs_find_ns+0x3a/0xe0                                                                                                                                                                                                  │
│[17366.501263]  cancel_delayed_work_sync+0x13/0x20                                                                                                                                                                                          │
│[17366.501267]  magicmouse_remove+0x20/0x40 [hid_magicmouse]                                                                                                                                                                                │
│[17366.501272]  hid_device_remove+0x45/0xd0 [hid]                                                                                                                                                                                           │
│[17366.501277]  device_remove+0x40/0x80                                                                                                                                                                                                     │
│[17366.501281]  device_release_driver_internal+0x20b/0x270                                                                                                                                                                                  │
│[17366.501283]  ? srso_alias_return_thunk+0x5/0x7f                                                                                                                                                                                          │
│[17366.501285]  device_release_driver+0x12/0x20                                                                                                                                                                                             │
│[17366.501290]  bus_remove_device+0xcb/0x140                                                                                                                                                                                                │
│[17366.501295]  device_del+0x161/0x3e0                                                                                                                                                                                                      │
│[17366.501298]  ? __hid_bpf_destroy_device+0x139/0x1a0                                                                                                                                                                                      │
│[17366.501304]  hid_destroy_device+0x55/0x70 [hid]                                                                                                                                                                                          │
│[17366.501312]  usbhid_disconnect+0x49/0x70 [usbhid]                                                                                                                                                                                        │
│[17366.501318]  usb_unbind_interface+0x8e/0x280                                                                                                                                                                                             │
│[17366.501323]  device_remove+0x65/0x80                                     
│[17366.501326]  device_release_driver_internal+0x20b/0x270                                                                                                                                                                                  │
│[17366.501328]  ? srso_alias_return_thunk+0x5/0x7f                                                                                                                                                                                          │
│[17366.501332]  device_release_driver+0x12/0x20                                                                                                                                                                                             │
│[17366.501334]  bus_remove_device+0xcb/0x140                                                                                                                                                                                                │
│[17366.501337]  device_del+0x161/0x3e0                                                                                                                                                                                                      │
│[17366.501340]  ? kobject_put+0x67/0xa0                                                                                                                                                                                                     │
│[17366.501345]  usb_disable_device+0xd5/0x280                                                                                                                                                                                               │
│[17366.501348]  usb_disconnect+0xe9/0x2e0                                                                                                                                                                                                   │
│[17366.501352]  hub_port_connect+0x90/0xc30                                                                                                                                                                                                 │
│[17366.501356]  ? srso_alias_return_thunk+0x5/0x7f                                                                                                                                                                                          │
│[17366.501359]  hub_port_connect_change+0x91/0x300                                                                                                                                                                                          │
│[17366.501363]  port_event+0x652/0x810                                                                                                                                                                                                      │
│[17366.501368]  hub_event+0x155/0x450                                                                                                                                                                                                       │
│[17366.501372]  process_one_work+0x23d/0x450                                                                                                                                                                                                │
│[17366.501376]  worker_thread+0x50/0x3f0                                                                                                                                                                                                    │
│[17366.501380]  ? __pfx_worker_thread+0x10/0x10                                                                                                                                                                                             │
│[17366.501382]  kthread+0xef/0x120                                                                                                                                                                                                          │
│[17366.501386]  ? __pfx_kthread+0x10/0x10                                                                                                                                                                                                   │
│[17366.501390]  ret_from_fork+0x44/0x70                                                                                                                                                                                                     │
│[17366.501394]  ? __pfx_kthread+0x10/0x10                                                                                                                                                                                                   │
│[17366.501397]  ret_from_fork_asm+0x1b/0x30                                                                                                                                                                                                 │
│[17366.501403]  </TASK>                                                                                                                                                                                                                     │
│[17366.501404] Modules linked in: rfcomm xt_multiport nft_compat nf_tables nfnetlink rpcsec_gss_krb5 auth_rpcgss nfsv4 nfs lockd grace fscache netfs vboxnetadp(OE) vboxnetflt(OE) vboxdrv(OE) bridge stp llc cmac algif_hash algif_skcipher│
│ af_alg bnep sunrpc binfmt_misc zfs(PO) spl(O) intel_rapl_msr intel_rapl_common snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg snd_usb_audio snd_intel_sdw_acpi snd_usbmidi_lib snd_hda_codec snd_ump mt7921e mc snd_hda_core edac_mce_am│
│d snd_hwdep mt7921_common snd_pcm mt76_connac_lib kvm_amd mt76 snd_seq_midi snd_seq_midi_event mac80211 snd_rawmidi kvm btusb btrtl snd_seq btbcm btintel irqbypass btmtk snd_seq_device rapl bluetooth hid_magicmouse(OE) snd_timer ch341 x│
│r_serial joydev xpad ecdh_generic cfg80211 usbserial snd input_leds apple_mfi_fastcharge nls_iso8859_1 ff_memless cdc_acm ecc gigabyte_wmi wmi_bmof ccp k10temp libarc4 soundcore mac_hid sch_fq_codel msr parport_pc ppdev lp parport efi_p│
│store ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov                                                                                                                                                     │
│[17366.501500]  async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear dm_mirror dm_region_hash dm_log hid_logitech_hidpp hid_logitech_dj uas usb_storage hid_generic usbhid hid amdgpu amdxcp iommu_v│
│2 drm_buddy gpu_sched i2c_algo_bit drm_suballoc_helper drm_ttm_helper ttm crct10dif_pclmul drm_display_helper crc32_pclmul polyval_clmulni polyval_generic cec ghash_clmulni_intel sha256_ssse3 rc_core sha1_ssse3 aesni_intel drm_kms_helpe│
│r nvme crypto_simd cryptd i2c_piix4 drm nvme_core ahci xhci_pci igc libahci xhci_pci_renesas nvme_common video wmi                                                                                                                          │
│[17366.501553] CR2: 0000000000000170                                                                                                                                                                                                        │
│[17366.501555] ---[ end trace 0000000000000000 ]---                                                                                                                                                                                         │
│[17367.245345] RIP: 0010:timer_delete+0x2c/0x90                                                                                                                                                                                             │
│[17367.245355] Code: 44 00 00 55 48 89 e5 41 55 41 54 45 31 e4 53 48 83 ec 10 65 48 8b 04 25 28 00 00 00 48 89 45 e0 31 c0 48 c7 45 d8 00 00 00 00 <48> 8b 47 08 48 85 c0 74 2e 48 8d 75 d8 48 89 fb e8 cf db ff ff 48                      │
│[17367.245358] RSP: 0018:ffffad1a97e7f828 EFLAGS: 00010046                                                                                                                                                                                  │
│[17367.245361] RAX: 0000000000000000 RBX: 0000000000000148 RCX: 0000000000000000                                                                                                                                                            │
│[17367.245363] RDX: ffffad1a97e7f890 RSI: 0000000000000001 RDI: 0000000000000168                                                                                                                                                            │
│[17367.245365] RBP: ffffad1a97e7f850 R08: 0000000000000001 R09: 0000000000000286                                                                                                                                                            │
│[17367.245367] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000                                                                                                                                                            │
│[17367.245368] R13: 0000000000000001 R14: ffff8a32e2c2d950 R15: 0000000000000080                                                                                                                                                            │
│[17367.245370] FS:  0000000000000000(0000) GS:ffff8a39f8880000(0000) knlGS:0000000000000000                                                                                                                                                 │
│[17367.245372] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033                                                                                                                                                                            │
│[17367.245374] CR2: 0000000000000170 CR3: 0000000121f42000 CR4: 0000000000750ee0                                                                                                                                                            │
│[17367.245375] PKRU: 55555554                                                                                        
RicardoEPRodrigues commented 6 months ago

Unfortunately, I do not have the time to update this driver. If you find a solution please do a PR or report it and I might bring it in.

To clarify, this driver was designed to support the Magic Mouse scrolling. Currently, it has been integrated with more recent Kernels (version 5.15 and up), so if you are using this particular driver installed through DKMS you can remove it and it should not impact your system (after a reboot).