c
for (skb = segs; skb; skb = skb->next) {
    skb->protocol = htons(ETH_P_NSH);
    if (skb_headroom(skb) >= nsh_len) {
        __skb_push(skb, nsh_len);
    } else {
        // Proper error handling: free the segment and the rest of the chain
        dev_kfree_skb_chain(skb); 
        segs = ERR_PTR(-ENOMEM);  // Indicate failure
        break; // Exit the loop
    }
}
