Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnrc_ipv6_nib: check if pkt is NULL on error #11182

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int gnrc_ipv6_nib_get_next_hop_l2addr(const ipv6_addr_t *dst,
/* _resolve_addr releases pkt only if not queued (in which case
* we also shouldn't release), but if netif is not defined we
* should release in any case. */
if (netif == NULL) {
if ((netif == NULL) && (pkt != NULL)) {
gnrc_icmpv6_error_dst_unr_send(ICMPV6_ERROR_DST_UNR_ADDR,
pkt);
gnrc_pktbuf_release_error(pkt, EHOSTUNREACH);
Expand All @@ -228,10 +228,14 @@ int gnrc_ipv6_nib_get_next_hop_l2addr(const ipv6_addr_t *dst,
memcpy(&route.next_hop, dst, sizeof(route.next_hop));
}
else {
gnrc_icmpv6_error_dst_unr_send(ICMPV6_ERROR_DST_UNR_NO_ROUTE,
pkt);
res = -ENETUNREACH;
gnrc_pktbuf_release_error(pkt, ENETUNREACH);
if (pkt != NULL) {
gnrc_icmpv6_error_dst_unr_send(
ICMPV6_ERROR_DST_UNR_NO_ROUTE,
pkt
);
gnrc_pktbuf_release_error(pkt, ENETUNREACH);
}
break;
}
}
Expand Down Expand Up @@ -1197,6 +1201,7 @@ static bool _resolve_addr(const ipv6_addr_t *dst, gnrc_netif_t *netif,
return false;
}
}
/* pkt != NULL already checked above */
else {
gnrc_icmpv6_error_dst_unr_send(ICMPV6_ERROR_DST_UNR_ADDR,
pkt);
Expand Down