Skip to content

Commit 82945a7

Browse files
rlubosdanieldegrasse
authored andcommitted
net: l2: ieee802154: Prevent NULL pointer access
In case address mode in a packet is none, the address pointer within mhr struct will not be set. Therefore, the pointer should not be used before address mode is verified inside ieee802154_check_dst_addr(). This was reported by UBSAN: subsys/net/l2/ieee802154ieee802154.c:296:41: runtime error: member access within null pointer of type 'struct ieee802154_address_field' Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 30c8702 commit 82945a7

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
@@ -293,7 +293,7 @@ static inline void swap_and_set_pkt_ll_addr(struct net_linkaddr *addr, bool has_
293293
*/
294294
static bool ieee802154_check_dst_addr(struct net_if *iface, struct ieee802154_mhr *mhr)
295295
{
296-
struct ieee802154_address_field_plain *dst_plain = &mhr->dst_addr->plain;
296+
struct ieee802154_address_field_plain *dst_plain;
297297
struct ieee802154_context *ctx = net_if_l2_data(iface);
298298
bool ret = false;
299299

@@ -313,6 +313,8 @@ static bool ieee802154_check_dst_addr(struct net_if *iface, struct ieee802154_mh
313313
return false;
314314
}
315315

316+
dst_plain = &mhr->dst_addr->plain;
317+
316318
k_sem_take(&ctx->ctx_lock, K_FOREVER);
317319

318320
/* c) If a destination PAN ID is included in the frame, it shall match

0 commit comments

Comments
 (0)