From patchwork Wed Jan 2 20:06:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 1924911 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 90456DF230 for ; Wed, 2 Jan 2013 20:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680Ab3ABUHV (ORCPT ); Wed, 2 Jan 2013 15:07:21 -0500 Received: from mail.ispras.ru ([83.149.199.43]:58024 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752636Ab3ABUHU (ORCPT ); Wed, 2 Jan 2013 15:07:20 -0500 Received: from localhost.localdomain (ppp91-79-124-37.pppoe.mtu-net.ru [91.79.124.37]) by mail.ispras.ru (Postfix) with ESMTP id 7AF3C24FE51; Thu, 3 Jan 2013 00:07:17 +0400 (MSK) From: Alexey Khoroshilov To: "John W. Linville" Cc: Alexey Khoroshilov , Christian Lamparter , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2] p54pci: don't return zero on failure paths in p54p_probe() Date: Thu, 3 Jan 2013 00:06:47 +0400 Message-Id: <1357157207-20626-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.7.9.5 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org If pci_set_dma_mask() or pci_set_consistent_dma_mask() fails in p54p_probe(), it breaks off initialization, deallocates all resources, but returns zero. Similar issue is if check for returned value of pci_resource_len() fails. The patch implements proper error code propagation. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Christian Lamparter --- drivers/net/wireless/p54/p54pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index 933e5d9..57e3af8 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c @@ -559,6 +559,7 @@ static int p54p_probe(struct pci_dev *pdev, mem_len = pci_resource_len(pdev, 0); if (mem_len < sizeof(struct p54p_csr)) { dev_err(&pdev->dev, "Too short PCI resources\n"); + err = -ENODEV; goto err_disable_dev; } @@ -568,8 +569,10 @@ static int p54p_probe(struct pci_dev *pdev, goto err_disable_dev; } - if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || - pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { dev_err(&pdev->dev, "No suitable DMA available\n"); goto err_free_reg; }