public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ramon Fried <rfried.dev@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] pci_ep: fix wrong addressing to barno
Date: Mon, 15 Jul 2019 23:04:41 +0300	[thread overview]
Message-ID: <20190715200441.5052-1-rfried.dev@gmail.com> (raw)

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

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;
 }
-- 
2.22.0

             reply	other threads:[~2019-07-15 20:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 20:04 Ramon Fried [this message]
2019-07-19  0:00 ` [U-Boot] [PATCH] pci_ep: fix wrong addressing to barno Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190715200441.5052-1-rfried.dev@gmail.com \
    --to=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox