The code fails to check if ops is non-NULL before using it's members.
Add the missing check and while at it, flip the condition to make it
more obvious what is actually happening.

Signed-off-by: Marek Vasut <marek.vasut+rene...@gmail.com>
Cc: Simon Glass <s...@chromium.org>
Cc: Tom Rini <tr...@konsulko.com>
---
 drivers/pci/pci-uclass.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index eb118f3496..de523a76ad 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -241,9 +241,9 @@ int pci_bus_write_config(struct udevice *bus, pci_dev_t 
bdf, int offset,
        struct dm_pci_ops *ops;
 
        ops = pci_get_ops(bus);
-       if (!ops->write_config)
-               return -ENOSYS;
-       return ops->write_config(bus, bdf, offset, value, size);
+       if (ops && ops->write_config)
+               return ops->write_config(bus, bdf, offset, value, size);
+       return -ENOSYS;
 }
 
 int pci_bus_clrset_config32(struct udevice *bus, pci_dev_t bdf, int offset,
@@ -321,9 +321,9 @@ int pci_bus_read_config(struct udevice *bus, pci_dev_t bdf, 
int offset,
        struct dm_pci_ops *ops;
 
        ops = pci_get_ops(bus);
-       if (!ops->read_config)
-               return -ENOSYS;
-       return ops->read_config(bus, bdf, offset, valuep, size);
+       if (ops && ops->read_config)
+               return ops->read_config(bus, bdf, offset, valuep, size);
+       return -ENOSYS;
 }
 
 int pci_read_config(pci_dev_t bdf, int offset, unsigned long *valuep,
-- 
2.18.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to