linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: FFA: Use pointers from memcpy() calls for assignments in three functions
@ 2025-10-30 17:40 Markus Elfring
  2025-10-30 18:07 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2025-10-30 17:40 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, Andrew Walbran, Ayrton Munoz,
	Catalin Marinas, Joey Gouly, Marc Zyngier, Oliver Upton,
	Per Larsen, Quentin Perret, Suzuki Poulouse, Will Deacon,
	Zenghui Yu
  Cc: LKML, kernel-janitors, Miaoqian Lin

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 30 Oct 2025 18:25:55 +0100

A pointer was assigned to a variable in three function implementations.
The same pointer was used for the destination parameter of a memcpy() call.
This function is documented in the way that the same value is returned.
Thus convert separate statements into direct variable assignments for
the return values from memory copy actions.

The source code was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/arm64/kvm/hyp/nvhe/ffa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
index 4e16f9b96f63..4820a9e96f80 100644
--- a/arch/arm64/kvm/hyp/nvhe/ffa.c
+++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
@@ -431,8 +431,7 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res,
 	if (!host_buffers.tx)
 		goto out_unlock;
 
-	buf = hyp_buffers.tx;
-	memcpy(buf, host_buffers.tx, fraglen);
+	buf = memcpy(hyp_buffers.tx, host_buffers.tx, fraglen);
 	nr_ranges = fraglen / sizeof(*buf);
 
 	ret = ffa_host_share_ranges(buf, nr_ranges);
@@ -505,8 +504,7 @@ static void __do_ffa_mem_xfer(const u64 func_id,
 		goto out_unlock;
 	}
 
-	buf = hyp_buffers.tx;
-	memcpy(buf, host_buffers.tx, fraglen);
+	buf = memcpy(hyp_buffers.tx, host_buffers.tx, fraglen);
 
 	ep_mem_access = (void *)buf +
 			ffa_mem_desc_offset(buf, 0, hyp_ffa_version);
@@ -615,8 +613,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_1_2_regs *res,
 		goto out_unlock;
 	}
 
-	buf = ffa_desc_buf.buf;
-	memcpy(buf, hyp_buffers.rx, fraglen);
+	buf = memcpy(ffa_desc_buf.buf, hyp_buffers.rx, fraglen);
 	ffa_rx_release(res);
 
 	for (fragoff = fraglen; fragoff < len; fragoff += fraglen) {
-- 
2.51.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-30 18:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 17:40 [PATCH] KVM: arm64: FFA: Use pointers from memcpy() calls for assignments in three functions Markus Elfring
2025-10-30 18:07 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).