From patchwork Tue Apr 12 11:46:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8809681 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 29E5A9F3A0 for ; Tue, 12 Apr 2016 11:47:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 591872035D for ; Tue, 12 Apr 2016 11:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B6722034F for ; Tue, 12 Apr 2016 11:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933358AbcDLLq5 (ORCPT ); Tue, 12 Apr 2016 07:46:57 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35628 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755418AbcDLLqz (ORCPT ); Tue, 12 Apr 2016 07:46:55 -0400 Received: by mail-pf0-f180.google.com with SMTP id n1so12591763pfn.2; Tue, 12 Apr 2016 04:46:55 -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=hKXZIwianipN5doE0NTs/sFBT4BRpzo+Mbx1ngTExmA=; b=PjZu1Pc2w1ZT+xJlJyMMmz/cExURPAFwpcZhx7IFHgdN4kavH0Tq5VrSiRrfEqfOzp I0MTkZJR3d9X55cpQx4a/j1Fad5nhcD4/FNsbMBGjXXumm3M/UkG9WNa7jbExy6Sp7Sz RY+HXJQl7KLbN6H7xxk/1HFit2lC54sUGC4Gw1pguk7jEL+b8Z5Ax5kI3oSXba3lGiZ5 qziqzWd0Ni2C8kq+ak7YZtQSzeOXHiIWR+27jEN/Anin14rNcsXoiu8spzhdf9ID/re3 ksl5+xnuqph3BYou7l/JX0MBx/SSJisXpl0Gtyahzsa9nyd5QhnpMOw+MQcs+oXIuFYj wQuA== 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=hKXZIwianipN5doE0NTs/sFBT4BRpzo+Mbx1ngTExmA=; b=N/m/Ba1blo7nWc4IyUSxIMi+66KFAump+NlbfirR1YZh1zOXdG99pA+7Xwz8DmZwof 8LEGLDPg21RpQnF0QGfnwZ6FcY17xFJn4ChCTBuHqDM2hPzbQILirYQOjigEnSARLAuj dtUOyTrH578qOLtGWXocAS1g35Bfq5NJdgC/EYQS5XO6wJaOKiihTp+1JS425Shu66m+ hFUGQthYL19TZz5C/PF/EhqJgNa+X+ZaYlyAwDUc+YzK7wz2NzPZ5TeCe2iwbrsKxdnk Nu1yKzQsuAg615xrJ3HPO9lSaFJmLyiIro5+lQPnYOJRlzgcqS/5lxnym6U23Jmo0Wjd Qldw== X-Gm-Message-State: AOPr4FWAqsCMf33Cw7+HMR0XUvZCLyhs4y//wH39o4eb0oMjS59NLgAvlz9SjRQ3XZiEvQ== X-Received: by 10.98.16.198 with SMTP id 67mr4006823pfq.21.1460461614881; Tue, 12 Apr 2016 04:46:54 -0700 (PDT) Received: from localhost.localdomain ([103.24.124.194]) by smtp.gmail.com with ESMTPSA id g74sm43133438pfj.1.2016.04.12.04.46.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Apr 2016 04:46:53 -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 , Christian Daudt Subject: [PATCH v2] mwifiex: fix possible NULL dereference Date: Tue, 12 Apr 2016 17:16:37 +0530 Message-Id: <1460461597-7309-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..d4db9db 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; int i; if (card) { + struct pci_dev *pdev = card->dev; + if (card->msix_enable) { for (i = 0; i < MWIFIEX_NUM_MSIX_VECTORS; i++) synchronize_irq(card->msix_entries[i].vector);