Skip to content

Commit

Permalink
virtio_net: use correct accessors for scatterlists
Browse files Browse the repository at this point in the history
Without this fix, virtio_net makes incorrect usage of scatterlists. It sets
the end of the scatterlist chain after the first element, despite the fact
that more entries come after it.

If you try to run dma_map_sg() on one of the scatterlists given to you by
add_buf(), you will get a null pointer oops.

Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ira W. Snyder authored and David S. Miller committed Jan 27, 2009
1 parent 5376071 commit 8527bec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
skb_put(skb, MAX_PACKET_LEN);

hdr = skb_vnet_hdr(skb);
sg_init_one(sg, hdr, sizeof(*hdr));
sg_set_buf(sg, hdr, sizeof(*hdr));

if (vi->big_packets) {
for (i = 0; i < MAX_SKB_FRAGS; i++) {
Expand Down Expand Up @@ -488,9 +488,9 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)

/* Encode metadata header at front. */
if (vi->mergeable_rx_bufs)
sg_init_one(sg, mhdr, sizeof(*mhdr));
sg_set_buf(sg, mhdr, sizeof(*mhdr));
else
sg_init_one(sg, hdr, sizeof(*hdr));
sg_set_buf(sg, hdr, sizeof(*hdr));

num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;

Expand Down

0 comments on commit 8527bec

Please sign in to comment.