diff options
author | Jason Wang <jasowang@redhat.com> | 2012-05-01 23:42:06 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2012-05-02 11:22:20 -0400 |
commit | 01d6657b388438def19c8baaea28e742b6ed32ec (patch) | |
tree | 7979049df013d023baa9f1a9ae7aa85e350e937c /drivers/net/macvtap.c | |
parent | 02ce04bb3d28c3333231f43bca677228dbc686fe (diff) |
macvtap: zerocopy: set SKBTX_DEV_ZEROCOPY only when skb is built successfully
Current the SKBTX_DEV_ZEROCOPY is set unconditionally after
zerocopy_sg_from_iovec(), this would lead NULL pointer when macvtap
fails to build zerocopy skb because destructor_arg was not
initialized. Solve this by set this flag after the skb were built
successfully.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/net/macvtap.c')
-rw-r--r-- | drivers/net/macvtap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index 9ab182a40648..a4ff694cea22 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -699,10 +699,9 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
699 | if (!skb) | 699 | if (!skb) |
700 | goto err; | 700 | goto err; |
701 | 701 | ||
702 | if (zerocopy) { | 702 | if (zerocopy) |
703 | err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count); | 703 | err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count); |
704 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; | 704 | else |
705 | } else | ||
706 | err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, | 705 | err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len, |
707 | len); | 706 | len); |
708 | if (err) | 707 | if (err) |
@@ -721,8 +720,10 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
721 | rcu_read_lock_bh(); | 720 | rcu_read_lock_bh(); |
722 | vlan = rcu_dereference_bh(q->vlan); | 721 | vlan = rcu_dereference_bh(q->vlan); |
723 | /* copy skb_ubuf_info for callback when skb has no error */ | 722 | /* copy skb_ubuf_info for callback when skb has no error */ |
724 | if (zerocopy) | 723 | if (zerocopy) { |
725 | skb_shinfo(skb)->destructor_arg = m->msg_control; | 724 | skb_shinfo(skb)->destructor_arg = m->msg_control; |
725 | skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; | ||
726 | } | ||
726 | if (vlan) | 727 | if (vlan) |
727 | macvlan_start_xmit(skb, vlan->dev); | 728 | macvlan_start_xmit(skb, vlan->dev); |
728 | else | 729 | else |