linux-next/drivers/net/netdevsim
Jakub Kicinski ea937f7720 net: netdevsim: don't try to destroy PHC on VFs
PHC gets initialized in nsim_init_netdevsim(), which
is only called if (nsim_dev_port_is_pf()).

Create a counterpart of nsim_init_netdevsim() and
move the mock_phc_destroy() there.

This fixes a crash trying to destroy netdevsim with
VFs instantiated, as caught by running the devlink.sh test:

    BUG: kernel NULL pointer dereference, address: 00000000000000b8
    RIP: 0010:mock_phc_destroy+0xd/0x30
    Call Trace:
     <TASK>
     nsim_destroy+0x4a/0x70 [netdevsim]
     __nsim_dev_port_del+0x47/0x70 [netdevsim]
     nsim_dev_reload_destroy+0x105/0x120 [netdevsim]
     nsim_drv_remove+0x2f/0xb0 [netdevsim]
     device_release_driver_internal+0x1a1/0x210
     bus_remove_device+0xd5/0x120
     device_del+0x159/0x490
     device_unregister+0x12/0x30
     del_device_store+0x11a/0x1a0 [netdevsim]
     kernfs_fop_write_iter+0x130/0x1d0
     vfs_write+0x30b/0x4b0
     ksys_write+0x69/0xf0
     do_syscall_64+0xcc/0x1e0
     entry_SYSCALL_64_after_hwframe+0x6f/0x77

Fixes: b63e78fca8 ("net: netdevsim: use mock PHC driver")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2024-01-17 10:56:44 +00:00
..
bpf.c netdevsim: Don't accept device bound programs 2023-11-23 13:04:04 -08:00
bus.c netdevsim: Block until all devices are released 2023-10-27 14:48:36 -07:00
dev.c netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write() 2023-07-12 12:46:35 -07:00
ethtool.c net: netdevsim: use mock PHC driver 2023-08-09 15:59:21 -07:00
fib.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-08-03 09:04:55 +02:00
health.c netdevsim: devlink health: use retained error fmsg API 2023-10-20 11:34:49 +01:00
hwstats.c netdevsim: Fix hwstats debugfs file permissions 2022-09-19 14:40:38 -07:00
ipsec.c netdevsim: Fill IPsec state validation failure reason 2023-01-26 16:28:48 -08:00
macsec.c net: macsec: move sci_to_cpu to macsec header 2023-12-27 13:08:09 +00:00
Makefile netdevsim: add dummy macsec offload 2023-07-14 09:16:53 +01:00
netdev.c net: netdevsim: don't try to destroy PHC on VFs 2024-01-17 10:56:44 +00:00
netdevsim.h net: netdevsim: use mock PHC driver 2023-08-09 15:59:21 -07:00
psample.c netdevsim: Only use sampling truncation length when valid 2021-04-22 13:23:56 -07:00
udp_tunnels.c netdevsim: set .owner to THIS_MODULE 2020-11-17 14:08:59 -08:00