Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964799AbbLSMGv (ORCPT ); Sat, 19 Dec 2015 07:06:51 -0500 Received: from mail.ispras.ru ([83.149.199.45]:50794 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932748AbbLSMGu (ORCPT ); Sat, 19 Dec 2015 07:06:50 -0500 Subject: Re: [PATCH] natsemi: add checks for dma mapping errors To: David Miller References: <1450475737-5959-1-git-send-email-khoroshilov@ispras.ru> <20151218.213607.1270121670262037282.davem@davemloft.net> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org From: Alexey Khoroshilov Message-ID: <56754855.6080808@ispras.ru> Date: Sat, 19 Dec 2015 15:06:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151218.213607.1270121670262037282.davem@davemloft.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1525 Lines: 47 On 19.12.2015 05:36, David Miller wrote: > From: Alexey Khoroshilov > Date: Sat, 19 Dec 2015 00:55:37 +0300 > >> @@ -2093,6 +2099,10 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev) >> np->tx_skbuff[entry] = skb; >> np->tx_dma[entry] = pci_map_single(np->pci_dev, >> skb->data,skb->len, PCI_DMA_TODEVICE); >> + if (pci_dma_mapping_error(np->pci_dev, np->tx_dma[entry])) { >> + np->tx_skbuff[entry] = NULL; >> + return NETDEV_TX_BUSY; >> + } >> >> np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]); >> > > Returning NETDEV_TX_BUSY and freeing the SKB will crash the system. I do not quite understand what do you mean by 'freeing the SKB'. At least the patch left skb untouched. But I saw such pattern, for example, in drivers/net/ethernet/freescale/fec_main.c: addr = dma_map_single(&fep->pdev->dev, data, size, DMA_TO_DEVICE); if (dma_mapping_error(&fep->pdev->dev, addr)) { dev_kfree_skb_any(skb); if (net_ratelimit()) netdev_err(ndev, "Tx DMA memory map failed\n"); return NETDEV_TX_BUSY; } > > NETDEV_TX_BUSY is only for buggy drivers that do not manage their > TX ring busy condition correctly, and thus need retries. Ok, I will replace NETDEV_TX_BUSY by dropping the packet. -- Alexey -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/