diff mbox series

[U-Boot] pci_ep: fix wrong addressing to barno

Message ID 20190715200441.5052-1-rfried.dev@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [U-Boot] pci_ep: fix wrong addressing to barno | expand

Commit Message

Ramon Fried July 15, 2019, 8:04 p.m. UTC
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>
---
 drivers/pci_endpoint/sandbox-pci_ep.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Tom Rini July 19, 2019, midnight UTC | #1
On Mon, Jul 15, 2019 at 11:04:41PM +0300, Ramon Fried wrote:

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

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/pci_endpoint/sandbox-pci_ep.c b/drivers/pci_endpoint/sandbox-pci_ep.c
index 0258433d8f..ca8871fc36 100644
--- a/drivers/pci_endpoint/sandbox-pci_ep.c
+++ b/drivers/pci_endpoint/sandbox-pci_ep.c
@@ -88,9 +88,7 @@  static int sandbox_read_bar(struct udevice *dev, uint fn,
 	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;
 }