From: Marcel Ziswiler <marcel.ziswi...@toradex.com> Given ahci_get_ops() being a macro not checking anything make sure we only call it if we do indeed have a dev pointer.
Signed-off-by: Marcel Ziswiler <marcel.ziswi...@toradex.com> --- drivers/ata/sata.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c index e384b805b2..4e41f09c87 100644 --- a/drivers/ata/sata.c +++ b/drivers/ata/sata.c @@ -20,9 +20,14 @@ struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; int sata_reset(struct udevice *dev) { - struct ahci_ops *ops = ahci_get_ops(dev); + struct ahci_ops *ops = NULL; - if (!ops->reset) + if (!dev) + return -ENODEV; + + ops = ahci_get_ops(dev); + + if (!ops || !ops->reset) return -ENOSYS; return ops->reset(dev); @@ -30,9 +35,14 @@ int sata_reset(struct udevice *dev) int sata_dm_port_status(struct udevice *dev, int port) { - struct ahci_ops *ops = ahci_get_ops(dev); + struct ahci_ops *ops = NULL; + + if (!dev) + return -ENODEV; - if (!ops->port_status) + ops = ahci_get_ops(dev); + + if (!ops || !ops->port_status) return -ENOSYS; return ops->port_status(dev, port); @@ -40,9 +50,14 @@ int sata_dm_port_status(struct udevice *dev, int port) int sata_scan(struct udevice *dev) { - struct ahci_ops *ops = ahci_get_ops(dev); + struct ahci_ops *ops = NULL; + + if (!dev) + return -ENODEV; + + ops = ahci_get_ops(dev); - if (!ops->scan) + if (!ops || !ops->scan) return -ENOSYS; return ops->scan(dev); -- 2.20.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot