• X
    pciehp: make 'slot_being_removed_rescanned' per root port · 834faefb
    Xiongfeng Wang 提交于
    hulk inclusion
    category: bugfix
    bugzilla: 20881
    CVE: NA
    ---------------------------
    
    We use a global variable 'slot_being_removed_rescaned' to mark whether a
    slot is being removed or rescaned. This will cause a slot hotplug
    operation is delayed if another slot is being remove or rescaned. But
    if these two slots are under different root ports, they should not
    influence each other. This patch make the flag
    'slot_being_removed_rescanned' per root port so that one slot hotplug
    operation doesn't influence slots below another root port.
    
    We record the root port in struct pci_dev when the pci device is
    initialized and added into the system instead of using
    'pcie_find_root_port()' to find the root port when we need it. Because
    iterating the pci tree needs the protection of
    'pci_lock_rescan_remove()'. This will make the problem more complexed
    because the lock is very coarse-grained. We don't need to worry about
    'use-after-free' because child pci devices are always removed before the
    root port device is removed.
    
    Fixes: 764cafd9875e ("pciehp: fix a race between pciehp and removing
    operations by sysfs")
    Signed-off-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
    Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    834faefb
pci.h 83.4 KB