From patchwork Sun Jul 30 08:02:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 9870227 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2CCD26038F for ; Sun, 30 Jul 2017 08:12:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11B4F285DA for ; Sun, 30 Jul 2017 08:12:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02950285E7; Sun, 30 Jul 2017 08:12:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4A9285DA for ; Sun, 30 Jul 2017 08:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753561AbdG3ICg (ORCPT ); Sun, 30 Jul 2017 04:02:36 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:34161 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751065AbdG3ICe (ORCPT ); Sun, 30 Jul 2017 04:02:34 -0400 Received: by mail-wr0-f195.google.com with SMTP id o33so21870610wrb.1; Sun, 30 Jul 2017 01:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PeHg1cVv9r2tgSaRVuaHjP4DMsTGldVVQi16HV/+poA=; b=g7WSi0Ko8If2/R6GOK71MvmXn1WpE2yIgxcah1tmRPxSFyPGBYSFw4GGg46sRTQ3em hOdLz2W3VBZoNAzcGWpLJiZpGdSPVAmZ0co6wretSaCmFz/nJFU/V0tC70lu9M2kmb5d bcbS6az0NBowwCVPZbZ9hktr96soIx57zuIHCWecIdn5za92G8feSth/BJaihUNNoeYk c4RD1NNLOHH5VexY6KE2HEs8+jzYrT7DJFDMZW/Aog0cOWP34EutlZGSr0Y/uS/MoQFd yOiH8GktXkCxvYbNKPi/7yEN99Aukyo75KVh9Rg7yFX32A+MDgWDfAzLS7BS1swy0uQQ t2Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PeHg1cVv9r2tgSaRVuaHjP4DMsTGldVVQi16HV/+poA=; b=L5UQUU4LcyCjZEghGoWu4YNI7qTTRzQGIdpVHMWyS6JicutaR97OFscwaTdEDRabjB KQp4cF/xopOCbbESL0Zv64LruJA1NudnkPZ1fsneqtaRY7rZ3xJBrul3tEAArpNSoJOb VYdCUei+FXSEj32iMnrY01K7Q8QcAgfsOosnGKhGau7WeJxsqQuEQ4oaf6uo2pQjDqRF E8iusCnRSHvaVyxxkavMnpOf7ZyVg8XPtFO6TUS9igJzVXVtyCgOtL/QutMO4p8HcLrx GVc4s7fAm21/FjF+wgQ3F52fbp/+KTLetIph57oDDyLTr/gVScf02eb3jP6pygSeIte5 o/oA== X-Gm-Message-State: AIVw110j7RJin5VHcU+C7WtlJ543+074vJKCEFiQ4Hb6ZsSNEtkJH4l2 1DVu0yZI5UI9G0Hp8/0= X-Received: by 10.223.147.164 with SMTP id 33mr10679905wrp.107.1501401752607; Sun, 30 Jul 2017 01:02:32 -0700 (PDT) Received: from localhost.localdomain (188.29.165.88.threembb.co.uk. [188.29.165.88]) by smtp.gmail.com with ESMTPSA id b23sm35017416wrd.40.2017.07.30.01.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jul 2017 01:02:32 -0700 (PDT) From: Malcolm Priestley To: linux-wireless@vger.kernel.org Cc: Larry Finger , Chaoming Li , Malcolm Priestley , stable@vger.kernel.org Subject: [PATCH][BUG] rtlwifi: rtl_pci_probe: Fix fail path of _rtl_pci_find_adapter Date: Sun, 30 Jul 2017 09:02:19 +0100 Message-Id: <20170730080219.5925-1-tvboxspy@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP _rtl_pci_find_adapter fail path will jump to label fail3 for unsupported adapter types. However, on course for fail3 there will be call rtl_deinit_core before rtl_init_core. For the inclusion of checking pci_iounmap this fail can be moved to fail2. Fixes [ 4.492963] BUG: unable to handle kernel NULL pointer dereference at (null) [ 4.493067] IP: rtl_deinit_core+0x31/0x90 [rtlwifi] Signed-off-by: Malcolm Priestley Cc: --- Although this is the first time I have encounted this bug in 4.13-rc1 there are some historical references so I have included stable. drivers/net/wireless/realtek/rtlwifi/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c index 032b6317690d..08dc8919ef60 100644 --- a/drivers/net/wireless/realtek/rtlwifi/pci.c +++ b/drivers/net/wireless/realtek/rtlwifi/pci.c @@ -2257,7 +2257,7 @@ int rtl_pci_probe(struct pci_dev *pdev, /* find adapter */ if (!_rtl_pci_find_adapter(pdev, hw)) { err = -ENODEV; - goto fail3; + goto fail2; } /* Init IO handler */ @@ -2318,10 +2318,10 @@ int rtl_pci_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, NULL); rtl_deinit_core(hw); +fail2: if (rtlpriv->io.pci_mem_start != 0) pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); -fail2: pci_release_regions(pdev); complete(&rtlpriv->firmware_loading_complete);