Skip to content

Commit 5917212

Browse files
arndbtiwai
authored andcommitted
ALSA: asihpi: avoid write overflow check warning
clang-22 rightfully warns that the memcpy() in adapter_prepare() copies between different structures, crossing the boundary of nested structures inside it: In file included from sound/pci/asihpi/hpimsgx.c:13: In file included from include/linux/string.h:386: include/linux/fortify-string.h:569:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] 569 | __write_overflow_field(p_size_field, size); The two structures seem to refer to the same layout, despite the separate definitions, so the code is in fact correct. Avoid the warning by copying the two inner structures separately. I see the same pattern happens in other functions in the same file, so there is a chance that this may come back in the future, but this instance is the only one that I saw in practice, hitting it multiple times per day in randconfig build. Signed-off-by: Arnd Bergmann <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 8306a78 commit 5917212

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

sound/pci/asihpi/hpimsgx.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,10 @@ static u16 adapter_prepare(u16 adapter)
581581
HPI_ADAPTER_OPEN);
582582
hm.adapter_index = adapter;
583583
hw_entry_point(&hm, &hr);
584-
memcpy(&rESP_HPI_ADAPTER_OPEN[adapter], &hr,
585-
sizeof(rESP_HPI_ADAPTER_OPEN[0]));
584+
memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].h, &hr,
585+
sizeof(rESP_HPI_ADAPTER_OPEN[adapter].h));
586+
memcpy(&rESP_HPI_ADAPTER_OPEN[adapter].a, &hr.u.ax.info,
587+
sizeof(rESP_HPI_ADAPTER_OPEN[adapter].a));
586588
if (hr.error)
587589
return hr.error;
588590

0 commit comments

Comments
 (0)