net: promiscuous: Fix crash in promiscuous mode
When a packet can't be cloned we crash as we try to initialize the cursor on a nullptr. We should check if we have a valid pointer, and if we don't we drop the packet along with a warning. Signed-off-by: Andreas Ålgård <aal@ixys.no>
This commit is contained in:
parent
47396e18e1
commit
fa0bbaf66c
1 changed files with 7 additions and 4 deletions
|
@ -4145,12 +4145,15 @@ enum net_verdict net_if_recv_data(struct net_if *iface, struct net_pkt *pkt)
|
|||
/* L2 has modified the buffer starting point, it is easier
|
||||
* to re-initialize the cursor rather than updating it.
|
||||
*/
|
||||
if (new_pkt) {
|
||||
net_pkt_cursor_init(new_pkt);
|
||||
|
||||
if (net_promisc_mode_input(new_pkt) == NET_DROP) {
|
||||
net_pkt_unref(new_pkt);
|
||||
}
|
||||
|
||||
} else {
|
||||
NET_WARN("promiscuous packet dropped, unable to clone packet");
|
||||
}
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
return verdict;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue