net: ethernet: bridge: Avoid null pointer access

If the packet cloning failed, bail out in order to avoid
null pointer access.

Fixes #81992
Coverity-CID: 434493

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-11-26 11:08:49 +02:00 committed by Benjamin Cabé
commit ed0dcca2fb

View file

@ -372,6 +372,11 @@ static enum net_verdict bridge_iface_process(struct net_if *iface,
*/
if (count > 2) {
send_pkt = net_pkt_clone(pkt, K_NO_WAIT);
if (send_pkt == NULL) {
NET_DBG("DROP: clone failed");
break;
}
net_pkt_ref(send_pkt);
} else {
send_pkt = net_pkt_ref(pkt);