Re: [PATCH v2 1/3] PCI/sysfs: Fix null pointer dereference during hotplug

From: duziming
Date: Mon Dec 29 2025 - 22:40:50 EST



在 2025/12/30 1:31, Bjorn Helgaas 写道:
On Wed, Dec 24, 2025 at 05:27:17PM +0800, Ziming Du wrote:
During the concurrent process of creating and rescanning in VF, the
resource files for the same pci_dev may be created twice. The second
creation attempt fails, resulting the res_attr in pci_dev to kfree(),
but the pointer is not set to NULL. This will subsequently lead to
dereferencing a null pointer when removing the device.

When we perform the following operation:
echo $vfcount > /sys/class/net/"$pfname"/device/sriov_numvfs &
Is the value of $vfcount relevant here? Can you use the actual values
here instead of the variables so this is more useful to others?

In fact, we directly use sriov_totalvfs here. In my opinion, the larger this value is,

the more likely it is to cause the issue.

sleep 0.5
echo 1 > /sys/bus/pci/rescan
pci_remove "$pfname"
system will crash as follows: