In the Linux kernel, the following vulnerability has been resolved: net: netdevsim: don't try to destroy PHC on VFs PHC gets initialized in nsiminitnetdevsim(), which is only called if (nsimdevportispf()). Create a counterpart of nsiminitnetdevsim() and move the mockphcdestroy() 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:mockphcdestroy+0xd/0x30 Call Trace: <TASK> nsimdestroy+0x4a/0x70 [netdevsim] _nsimdevportdel+0x47/0x70 [netdevsim] nsimdevreloaddestroy+0x105/0x120 [netdevsim] nsimdrvremove+0x2f/0xb0 [netdevsim] devicereleasedriverinternal+0x1a1/0x210 busremovedevice+0xd5/0x120 devicedel+0x159/0x490 deviceunregister+0x12/0x30 deldevicestore+0x11a/0x1a0 [netdevsim] kernfsfopwriteiter+0x130/0x1d0 vfswrite+0x30b/0x4b0 ksyswrite+0x69/0xf0 dosyscall64+0xcc/0x1e0 entrySYSCALL64afterhwframe+0x6f/0x77