Skip to content

Commit 629253b

Browse files
arndbsudeep-holla
authored andcommitted
firmware: arm_ffa: Avoid string-fortify warning in export_uuid()
Copying to a 16 byte structure into an 8-byte struct member causes a compile-time warning: | In file included from drivers/firmware/arm_ffa/driver.c:25: | In function 'fortify_memcpy_chk', | inlined from 'export_uuid' at include/linux/uuid.h:88:2, | inlined from 'ffa_msg_send_direct_req2' at drivers/firmware/arm_ffa/driver.c:488:2: | include/linux/fortify-string.h:571:25: error: call to '__write_overflow_field' | declared with attribute warning: detected write beyond size of field | (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] | __write_overflow_field(p_size_field, size); Use a union for the conversion instead and make sure the byte order is fixed in the process. Fixes: aaef3bc ("firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2") Signed-off-by: Arnd Bergmann <[email protected]> Message-Id: <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 9852d85 commit 629253b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/firmware/arm_ffa/driver.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,16 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid,
481481
struct ffa_send_direct_data2 *data)
482482
{
483483
u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id);
484+
union {
485+
uuid_t uuid;
486+
__le64 regs[2];
487+
} uuid_regs = { .uuid = *uuid };
484488
ffa_value_t ret, args = {
485-
.a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids,
489+
.a0 = FFA_MSG_SEND_DIRECT_REQ2,
490+
.a1 = src_dst_ids,
491+
.a2 = le64_to_cpu(uuid_regs.regs[0]),
492+
.a3 = le64_to_cpu(uuid_regs.regs[1]),
486493
};
487-
488-
export_uuid((u8 *)&args.a2, uuid);
489494
memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data));
490495

491496
invoke_ffa_fn(args, &ret);

0 commit comments

Comments
 (0)