Thread (9 messages) flat view 9 messages, 2 authors, 2016-08-10

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

From: Mauricio Faria de Oliveira <hidden>
Date: 2016-08-10 12:30:21

On 08/10/2016 12:35 AM, Andrew Donnellan wrote:
quoted
     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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help