From: Ramon Fried Date: Mon, 15 Jul 2019 20:04:41 +0000 (+0300) Subject: pci_ep: fix wrong addressing to barno X-Git-Tag: v2019.10-rc1~24^2~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=eb18742575158a680070002cf182b0c64311c1b2;p=oweals%2Fu-boot.git pci_ep: fix wrong addressing to barno 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 [trini: Drop unused bar_idx] Signed-off-by: Tom Rini --- diff --git a/drivers/pci_endpoint/sandbox-pci_ep.c b/drivers/pci_endpoint/sandbox-pci_ep.c index 0258433d8f..8e05d5ba89 100644 --- a/drivers/pci_endpoint/sandbox-pci_ep.c +++ b/drivers/pci_endpoint/sandbox-pci_ep.c @@ -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; }