Commit eb187425 authored by Ramon Fried's avatar Ramon Fried Committed by Tom Rini
Browse files

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: bb413337

 ("pci_ep: add pci endpoint sandbox driver")
Signed-off-by: Ramon Fried's avatarRamon Fried <rfried.dev@gmail.com>
[trini: Drop unused bar_idx]
Signed-off-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
parent 80f485f6
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment