[PATCH v2 2/2] powerpc: update pci_controller.refcount for PCI devices and buses

Mauricio Faria de Oliveira mauricfo at linux.vnet.ibm.com
Wed Aug 10 22:30:10 AEST 2016

On 08/10/2016 12:35 AM, Andrew Donnellan wrote:
>>      if (phb->controller_ops.release_device)
>>          phb->controller_ops.release_device(dev);
>> +
>> +    if (unlikely(!phb))
>> +        pr_warn("%s: PCI device %s has null PHB; refcount bug!",
>> +            __func__, dev_name(&dev->dev)); /* WARN_ON ahead */
> This should probably go before trying to dereference phb->controller_ops
> above?

You're right; I misplaced this check; will fix that.

Just a bit of explanation/history:

While trying to understand why I didn't hit that null dereference
when I initially hit the WARN_ON (the reason for the 'small change'
in the commit description), I found that back then I checked for
'pci_dev->sysdata' directly (not 'phb' -- early stages of the patch).

The former indeed was null, as it didn't inherit 'pci_bus->sysdata'
on pseries, but the code uses 'phb = dev->bus->sysdata' (and this
was not null as pci_bus->sysdata was actually set).

Mauricio Faria de Oliveira
IBM Linux Technology Center

More information about the Linuxppc-dev mailing list