Handle memory allocation failure in dp_output_control().
authorBen Pfaff <blp@nicira.com>
Wed, 23 Apr 2008 19:24:32 +0000 (12:24 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 23 Apr 2008 19:24:32 +0000 (12:24 -0700)
Possible fix for bug observed on OF6k.

datapath/datapath.c

index 054c47e5825aaa1176b32ff6d1be44bb6f0a3b6e..8a399fbe5b5bc57c9f6e66684ca1d8f6f9703cab 100644 (file)
@@ -594,6 +594,10 @@ dp_output_control(struct datapath *dp, struct sk_buff *skb,
 
        opi_len = offsetof(struct ofp_packet_in, data) + fwd_len;
        opi = alloc_openflow_skb(dp, opi_len, OFPT_PACKET_IN, NULL, &f_skb);
+       if (!opi) {
+               err = -ENOMEM;
+               goto out;
+       }
        opi->buffer_id      = htonl(buffer_id);
        opi->total_len      = htons(skb->len);
        opi->in_port        = htons(skb->dev->br_port->port_no);
@@ -602,8 +606,8 @@ dp_output_control(struct datapath *dp, struct sk_buff *skb,
        memcpy(opi->data, skb_mac_header(skb), fwd_len);
        err = send_openflow_skb(f_skb, NULL);
 
+out:
        kfree_skb(skb);
-
        return err;
 }