Re: [PATCH] wifi: ath12k: fix MAC address copy on big endian
From: Baochen Qiang
Date: Wed Mar 18 2026 - 23:00:46 EST
On 3/17/2026 7:22 PM, Alexander Wilhelm wrote:
> The ath12k_dp_get_mac_addr function performs a simple memcpy from a
> CPU-native data types into an u8 array. On a big-endian architecture, this
> later results in a null‑pointer dereference. Convert the data to
curious how could this happen? how matter the endian, it is just six bytes which are not a
pointer hence can not be dereferenced, no?
> little‑endian first, then copy it into the target array.
>
> Signed-off-by: Alexander Wilhelm <alexander.wilhelm@xxxxxxxxxxxx>
> ---
> drivers/net/wireless/ath/ath12k/dp.h | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/dp.h b/drivers/net/wireless/ath/ath12k/dp.h
> index f8cfc7bb29dd..50957915dbf4 100644
> --- a/drivers/net/wireless/ath/ath12k/dp.h
> +++ b/drivers/net/wireless/ath/ath12k/dp.h
> @@ -647,8 +647,11 @@ int ath12k_dp_arch_rx_tid_delete_handler(struct ath12k_dp *dp,
>
> static inline void ath12k_dp_get_mac_addr(u32 addr_l32, u16 addr_h16, u8 *addr)
> {
> - memcpy(addr, &addr_l32, 4);
> - memcpy(addr + 4, &addr_h16, ETH_ALEN - 4);
> + __le32 le_addr_l32 = cpu_to_le32(addr_l32);
> + __le16 le_addr_h16 = cpu_to_le16(addr_h16);
> +
> + memcpy(addr, &le_addr_l32, 4);
> + memcpy(addr + 4, &le_addr_h16, ETH_ALEN - 4);
> }
>
> static inline struct ath12k_dp *
>
> ---
> base-commit: 702847e8cfd51856836a282db2073defd7cfd80c
> change-id: 20260317-fix-mac-addr-copy-on-big-endian-f1a4fea40184
>
> Best regards,