]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pci_ep: fix wrong addressing to barno
authorRamon Fried <rfried.dev@gmail.com>
Mon, 15 Jul 2019 20:04:41 +0000 (23:04 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 18 Jul 2019 15:31:32 +0000 (11:31 -0400)
barno was mistakely readed from the target structure,
resulting in undefined behavious depending on the previous memory
content. fix that.

Fixes: bb413337826e ("pci_ep: add pci endpoint sandbox driver")
Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
[trini: Drop unused bar_idx]
Signed-off-by: Tom Rini <trini@konsulko.com>
drivers/pci_endpoint/sandbox-pci_ep.c

index 0258433d8f93de9ed46cd6f661eecc08cda82c8a..8e05d5ba8906dd1f19dfb5b4b3973b017a7a0091 100644 (file)
@@ -83,14 +83,11 @@ static int sandbox_read_bar(struct udevice *dev, uint fn,
                            struct pci_bar *ep_bar, enum pci_barno barno)
 {
        struct sandbox_pci_ep_priv *priv = dev_get_priv(dev);
-       int bar_idx;
 
        if (fn > 0)
                return -ENODEV;
 
-       bar_idx = ep_bar->barno;
-
-       memcpy(ep_bar, &priv->bars[bar_idx], sizeof(*ep_bar));
+       memcpy(ep_bar, &priv->bars[barno], sizeof(*ep_bar));
 
        return 0;
 }