From patchwork Thu Jan 21 11:42:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 43427 X-Patchwork-Delegate: davem@davemloft.net 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 8FD2EB7CFE for ; Thu, 21 Jan 2010 22:46:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752299Ab0AULqH (ORCPT ); Thu, 21 Jan 2010 06:46:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752241Ab0AULqG (ORCPT ); Thu, 21 Jan 2010 06:46:06 -0500 Received: from ozlabs.org ([203.10.76.45]:45346 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938Ab0AULqF (ORCPT ); Thu, 21 Jan 2010 06:46:05 -0500 Received: by ozlabs.org (Postfix, from userid 1010) id 3AFFCB7CFF; Thu, 21 Jan 2010 22:46:02 +1100 (EST) Date: Thu, 21 Jan 2010 22:42:44 +1100 From: Anton Blanchard To: Jeff Kirsher , Jesse Brandeburg , Bruce Allan , PJ Waskiewicz , John Ronciak , Don Skidmore , Yi Zou , Alexander Duyck Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org Subject: [PATCH 1/2] e1000: Fix DMA mapping error handling on TX Message-ID: <20100121114244.GC32259@kryten> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There were a few issues in the DMA mapping error handling in e1000_tx_map which I found via fault injection. If we fail to map the first descriptor count will end up as -1 but the check of (count >= 0) will still be true since count is unsigned. Instead of changing count to be signed, just simplify the logic. Secondly, when we wrap the tx ring we rely on i to go negative, but it was unsigned. Signed-off-by: Anton Blanchard --- -- 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 Index: linux.trees.git/drivers/net/e1000/e1000_main.c =================================================================== --- linux.trees.git.orig/drivers/net/e1000/e1000_main.c 2010-01-21 11:10:00.000000000 +1100 +++ linux.trees.git/drivers/net/e1000/e1000_main.c 2010-01-21 11:12:52.000000000 +1100 @@ -2693,8 +2693,9 @@ static int e1000_tx_map(struct e1000_ada struct pci_dev *pdev = adapter->pdev; struct e1000_buffer *buffer_info; unsigned int len = skb_headlen(skb); - unsigned int offset = 0, size, count = 0, i; + unsigned int offset = 0, size, count = 0; unsigned int f; + int i; i = tx_ring->next_to_use; @@ -2802,10 +2803,8 @@ static int e1000_tx_map(struct e1000_ada dma_error: dev_err(&pdev->dev, "TX DMA map failed\n"); buffer_info->dma = 0; - count--; - while (count >= 0) { - count--; + while (count--) { i--; if (i < 0) i += tx_ring->count;