public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Rick Chen <rick@andestech.com>
To: <samuel@sholland.org>, <ycliang@andestech.com>,
	<rick@andestech.com>, <rickchen36@gmail.com>
Cc: <u-boot@lists.denx.de>
Subject: [PATCH v3 2/2] riscv: memcpy: check src and dst before copy
Date: Wed, 4 Jan 2023 09:56:28 +0800	[thread overview]
Message-ID: <20230104015628.29787-1-rick@andestech.com> (raw)

Add src and dst address checking, if they
are the same address, just return and don't
copy data anymore.

Signed-off-by: Rick Chen <rick@andestech.com>
---
Changes in v3
- new patch: separate from [1/2]
---
 arch/riscv/lib/memcpy.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/riscv/lib/memcpy.S b/arch/riscv/lib/memcpy.S
index 00672c19ad..9884077c93 100644
--- a/arch/riscv/lib/memcpy.S
+++ b/arch/riscv/lib/memcpy.S
@@ -9,6 +9,7 @@
 /* void *memcpy(void *, const void *, size_t) */
 ENTRY(__memcpy)
 WEAK(memcpy)
+	beq	a0, a1, .copy_end
 	/* Save for return value */
 	mv	t6, a0
 
@@ -121,6 +122,7 @@ WEAK(memcpy)
 2:
 
 	mv	a0, t6
+.copy_end:
 	ret
 
 .Lmisaligned_word_copy:
-- 
2.17.1


             reply	other threads:[~2023-01-04  1:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  1:56 Rick Chen [this message]
2023-01-31 15:00 ` [PATCH v3 2/2] riscv: memcpy: check src and dst before copy Leo Liang

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=20230104015628.29787-1-rick@andestech.com \
    --to=rick@andestech.com \
    --cc=rickchen36@gmail.com \
    --cc=samuel@sholland.org \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /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