hard_iface = container_of(ptype, struct batadv_hard_iface,
                                  batman_adv_ptype);
+
+       /* Prevent processing a packet received on an interface which is getting
+        * shut down otherwise the packet may trigger de-reference errors
+        * further down in the receive path.
+        */
+       if (!kref_get_unless_zero(&hard_iface->refcount))
+               goto err_out;
+
        skb = skb_share_check(skb, GFP_ATOMIC);
 
        /* skb was released by skb_share_check() */
        if (!skb)
-               goto err_out;
+               goto err_put;
 
        /* packet should hold at least type and version */
        if (unlikely(!pskb_may_pull(skb, 2)))
        if (ret == NET_RX_DROP)
                kfree_skb(skb);
 
+       batadv_hardif_put(hard_iface);
+
        /* return NET_RX_SUCCESS in any case as we
         * most probably dropped the packet for
         * routing-logical reasons.
 
 err_free:
        kfree_skb(skb);
+err_put:
+       batadv_hardif_put(hard_iface);
 err_out:
        return NET_RX_DROP;
 }