Testing the return value of list_entry() for NULL is a no-op (as it is
just a fancy container_of() / offsetof()). Drop the superfluous if-clause
and instead verify the actual root-node is available. This is probably
what it was meant to test for from the beginning, anyway.

Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
---
 drivers/gpu/drm/drm_fops.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index a402061..afba0bf 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -330,11 +330,11 @@ static int drm_open_helper(struct file *filp, struct 
drm_minor *minor)
                        dev->hose = pci_dev->sysdata;
                        pci_dev_put(pci_dev);
                }
-               if (!dev->hose) {
+
+               if (!dev->hose && pci_root_buses.next) {
                        struct pci_bus *b = list_entry(pci_root_buses.next,
-                               struct pci_bus, node);
-                       if (b)
-                               dev->hose = b->sysdata;
+                                                      struct pci_bus, node);
+                       dev->hose = b->sysdata;
                }
        }
 #endif
-- 
2.0.2

Reply via email to