From patchwork Tue Jan 27 04:51:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 20396 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 797E4DE117 for ; Tue, 27 Jan 2009 15:51:32 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846AbZA0Ev2 (ORCPT ); Mon, 26 Jan 2009 23:51:28 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751750AbZA0Ev1 (ORCPT ); Mon, 26 Jan 2009 23:51:27 -0500 Received: from ozlabs.org ([203.10.76.45]:59281 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751372AbZA0Ev1 (ORCPT ); Mon, 26 Jan 2009 23:51:27 -0500 Received: from vivaldi.localnet (unknown [150.101.102.135]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id EFE4EDE115; Tue, 27 Jan 2009 15:51:25 +1100 (EST) From: Rusty Russell To: Ira Snyder Subject: Re: [PATCH] virtio_net: use correct accessors for scatterlists Date: Tue, 27 Jan 2009 15:21:19 +1030 User-Agent: KMail/1.10.3 (Linux/2.6.27-9-generic; KDE/4.1.3; i686; ; ) Cc: linux-kernel@vger.kernel.org, Mark McLoughlin , netdev@vger.kernel.org, "David S. Miller" References: <20090124001053.GA20156@ovro.caltech.edu> In-Reply-To: <20090124001053.GA20156@ovro.caltech.edu> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200901271521.19616.rusty@rustcorp.com.au> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Saturday 24 January 2009 10:40:53 Ira Snyder wrote: > 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 Thanks, this should go in 2.6.29. Dave? Cheers, Rusty. Subject: virtio_net: use correct accessors for scatterlists Date: Fri, 23 Jan 2009 16:10:53 -0800 From: Ira Snyder 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 Signed-off-by: Rusty Russell --- drivers/net/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 43f6523..67ea2cf 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -286,7 +286,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++) { @@ -487,9 +487,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;