From patchwork Mon Apr 11 15:27:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8803541 X-Patchwork-Delegate: kvalo@adurom.com 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E9EE5C0553 for ; Mon, 11 Apr 2016 15:28:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12AC32015E for ; Mon, 11 Apr 2016 15:28:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E53D620256 for ; Mon, 11 Apr 2016 15:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754539AbcDKP1z (ORCPT ); Mon, 11 Apr 2016 11:27:55 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:33413 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbcDKP1y (ORCPT ); Mon, 11 Apr 2016 11:27:54 -0400 Received: by mail-pa0-f43.google.com with SMTP id zm5so123497206pac.0; Mon, 11 Apr 2016 08:27:54 -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=f7c8HMjtGXdFsrsd2i0C4VsHChAy5KMBFImf9heeBNg=; b=HQAFFbYCmlZacocIIQy6aBiSoL3ADRQOdlKei3L5zOYQ7645jkfCBjsPKGMzKOuV1v hLlOzfEU82OenQ7Fn3s2vQUOq3u5D2pYToz4r4jdJCTGHJDVnxxxNMzkdhh9FZs2bBQe yOFBcjsRxvsBpXIe8RnqCtyDDIMWQq2n7JaiXnDsGo8xjp61w++xBdzO9zMXmJ+QwOYr 8w7a0HzoFQBty9gOQrRJ9nuQKr55fV8tjZsrG10ZJcU3+aSi+KcPC9EOENZu3guk3vok UKJG0VOZldS5jMvFG1uGvb9c6qr1q4APgIHogJBqp2o/bAvmSDwEQt/+IsA49bjNlGef rcbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f7c8HMjtGXdFsrsd2i0C4VsHChAy5KMBFImf9heeBNg=; b=iik4d6jSfBJlqiGoVW4RmwYVbjrl+VaBwVKaxEMQwLLUYFdn9gxcMIv6DIKJZMoXsR wLK3sKIDjuNgU60f9YO3wWHBAEcdp2bdtoxVb34J94N3Vtmmq1wfwhyAxxvIMK3prTJh tAyPcobNFOycNiaFxgH7eS9b3l/map6BZBpjeoajeWfwRyRCgf1F1feop0NoUCf1+tEe AzoweQBr761Qd+FIZL0NkwwSFGn+R5EvFqdd2xZF6zhVEyhUeThWa6oLqiwQnMU1wy2H K8D5E2qJ+souTanr1hQtbNt8crze3AjLV+AQvDNE3RLT3L1RXXJCx5v+QNcuDjniNLfQ SRBA== X-Gm-Message-State: AD7BkJIyMdKHDb3cWx4jen/UU5adqEq4MB4wdbvgPi3tufEAuRbmqA056BZsceldvV7TEg== X-Received: by 10.66.164.39 with SMTP id yn7mr33574654pab.107.1460388473567; Mon, 11 Apr 2016 08:27:53 -0700 (PDT) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id fw9sm37171849pac.21.2016.04.11.08.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Apr 2016 08:27:52 -0700 (PDT) From: Sudip Mukherjee To: Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] mwifiex: fix possible NULL dereference Date: Mon, 11 Apr 2016 20:57:39 +0530 Message-Id: <1460388459-21090-1-git-send-email-sudipm.mukherjee@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=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Sudip Mukherjee We have a check for card just after dereferencing it. So if it is NULL we have already dereferenced it before its check. Lets dereference it after checking card for NULL. Signed-off-by: Sudip Mukherjee --- drivers/net/wireless/marvell/mwifiex/pcie.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index edf8b07..84562d0 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -2884,10 +2884,11 @@ static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) { struct pcie_service_card *card = adapter->card; const struct mwifiex_pcie_card_reg *reg; - struct pci_dev *pdev = card->dev; + struct pci_dev *pdev; int i; if (card) { + pdev = card->dev; if (card->msix_enable) { for (i = 0; i < MWIFIEX_NUM_MSIX_VECTORS; i++) synchronize_irq(card->msix_entries[i].vector);