From patchwork Mon Jun 30 16:19:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 4452921 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58DF9BEEAA for ; Mon, 30 Jun 2014 16:19:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A3BA202F8 for ; Mon, 30 Jun 2014 16:19:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5CB4202DD for ; Mon, 30 Jun 2014 16:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932131AbaF3QTw (ORCPT ); Mon, 30 Jun 2014 12:19:52 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:59322 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754233AbaF3QTw (ORCPT ); Mon, 30 Jun 2014 12:19:52 -0400 Received: by mail-wi0-f174.google.com with SMTP id bs8so6382969wib.1 for ; Mon, 30 Jun 2014 09:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zXa1iVzF8D7+xCiYD7GivWU6gPA264D6FmJZOWOmSKE=; b=JuoONrBxyViBhDgayRDTNG7JgrXHMu6t/DDxNq+Kfr86flJIG0DRQanjpbLNhNNBl0 hc8JKM3athlDqEbKCFoDxkUt36oLRGW3Tp5JcXc4EJyRCGcZQKWTyVn2kLUYInl39BTe EpIM1gNKXla0W+2jwTNFWtVSXL9hZ/+POyCHPuChUUOLK9AjzXIegMIxKLT/hfUGu4vH AHX6gP0ansilITXRx2Si6x2TBv2/hDAVTGQYJcztINiFuw6oup2XWZQTnJoy+STjLVwY vnV8MiMB4z6Ravl1SmofriNiW6Jzt6fxlslQ3Hbuzugr4WMyUji3UEAqFQ50clQA8k6m WPQQ== X-Received: by 10.194.60.110 with SMTP id g14mr4674130wjr.101.1404145191051; Mon, 30 Jun 2014 09:19:51 -0700 (PDT) Received: from localhost.localdomain (host174-123-dynamic.6-79-r.retail.telecomitalia.it. [79.6.123.174]) by mx.google.com with ESMTPSA id ec8sm14063396wic.10.2014.06.30.09.19.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jun 2014 09:19:50 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, Andrea Merello Subject: [PATCH 7/7] rtl818x_pci: fix pci probe returns success when it fails Date: Mon, 30 Jun 2014 18:19:40 +0200 Message-Id: <1404145180-16248-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are several exit path from the PCI probe function. Some of them, that are taken in case of errors, forget to set the "err" variable, that is returned by the probe function. This can lead to the kernel thinking the probe function succeeds while it didn't, and this in turn causes extra calls to the "remove" function. This patch fix this problem by ensuring "err" variable is assigned to a proper non-zero value in each exit path. Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 68304a9..4b904f70 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -1756,6 +1756,7 @@ static int rtl8180_probe(struct pci_dev *pdev, if (!priv->map) { dev_err(&pdev->dev, "Cannot map device memory/PIO\n"); + err = -ENOMEM; goto err_free_dev; } @@ -1816,6 +1817,7 @@ static int rtl8180_probe(struct pci_dev *pdev, default: printk(KERN_ERR "%s (rtl8180): Unknown chip! (0x%x)\n", pci_name(pdev), reg >> 25); + err = -ENODEV; goto err_iounmap; } @@ -1866,12 +1868,14 @@ static int rtl8180_probe(struct pci_dev *pdev, default: printk(KERN_ERR "%s (rtl8180): Unknown RF! (0x%x)\n", pci_name(pdev), priv->rf_type); + err = -ENODEV; goto err_iounmap; } if (!priv->rf) { printk(KERN_ERR "%s (rtl8180): %s RF frontend not supported!\n", pci_name(pdev), rf_name); + err = -ENODEV; goto err_iounmap; }