Skip to content

Commit 236ccd3

Browse files
aescolardanieldegrasse
authored andcommitted
net: ieee802154: Do not access addr of unaligned struct
Use UNALIGNED_MEMBER_ADDR when getting the address of possibly unaligned structures members instead of attempting to directly get the address as an offset. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
1 parent 93fa3b7 commit 236ccd3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/net/l2/ieee802154/ieee802154.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_ieee802154, CONFIG_NET_L2_IEEE802154_LOG_LEVEL);
1616

1717
#include <errno.h>
1818

19+
#include <zephyr/toolchain/gcc.h>
1920
#include <zephyr/net/capture.h>
2021
#include <zephyr/net/ethernet.h>
2122
#include <zephyr/net/net_core.h>
@@ -264,7 +265,8 @@ static inline void swap_and_set_pkt_ll_addr(struct net_linkaddr *addr, bool has_
264265
(void)net_linkaddr_create(
265266
addr,
266267
(const uint8_t *)(has_pan_id ?
267-
&ll->plain.addr.short_addr : &ll->comp.addr.short_addr),
268+
UNALIGNED_MEMBER_ADDR(ll, plain.addr.short_addr) :
269+
UNALIGNED_MEMBER_ADDR(ll, comp.addr.short_addr)),
268270
IEEE802154_SHORT_ADDR_LENGTH,
269271
NET_LINK_IEEE802154);
270272
break;

0 commit comments

Comments
 (0)