From patchwork Tue Dec 20 21:09:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 9482241 X-Patchwork-Delegate: sameo@linux.intel.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 BB7DD60820 for ; Tue, 20 Dec 2016 21:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B098328342 for ; Tue, 20 Dec 2016 21:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5BB7283E8; Tue, 20 Dec 2016 21:09:19 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 1EA02283D4 for ; Tue, 20 Dec 2016 21:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936323AbcLTVJP (ORCPT ); Tue, 20 Dec 2016 16:09:15 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35686 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932646AbcLTVJM (ORCPT ); Tue, 20 Dec 2016 16:09:12 -0500 Received: by mail-wm0-f66.google.com with SMTP id l2so1196179wml.2; Tue, 20 Dec 2016 13:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hkAcjZBjPiAahtIdxToFgX+maaYTEtv0dzOvgjY1GCc=; b=JLlnTzs8XLsY7OwgNuUy+BETxqVIpcplR8nZFJAHAdTk7WBRYQq6uQjugjPIl72C1y DMny8duu0PnKVRkbfCb9w0+UrHNEmmW6tmjNessY3PvRKzmQjvamvn2ofeuWCjDYqCLX 4DruSAquWZZseYIR7d5eeBvVfkC7p4ZILFchm5lfKp38UrP6W2xfiU3VuoQ1dK49+CPv gmCXbYHvzddEvMvMPF4EJsPIZ3jiQxHr1BHRoB9UlrqOKvk0C9Uidjzp3LJoBVt8uO9p nC6bLQXzthe9MMIsQzRMGoVjuyKpdrp8QRRuZVMedhtTL2XYffB90GunhijX6BensVxo WNvg== 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=hkAcjZBjPiAahtIdxToFgX+maaYTEtv0dzOvgjY1GCc=; b=oDmoAFyHK9DDPFelgeG7B0s3W1Tu0+W5Xxw/CveTh41dkkHWFv9D1Hr65XdELuzTtN F3zIVOivz4dmpG/KQA6wi58u/h/WajwxZcZCNZWGMYA96uo9h8/7DhYVaBc+pBAdzTzq 1BKsD3I7REsNzeGkAD2EPTpvjioEj/9fuBRauL7aC6UlCIsVDcULs8kuv2Q/Hp2NpX6p Z2XGnM7fMhbiJaheum5/AY7BfD+rm5SkwFbOAEvfNqN1Fwgf9XFnWQe2y8Cz8nyWH7ey 7ApL+KwuhJpqQr/X8DX9WOriOPhWsiIeuxr+NjM0Um7EZlssFY8C5rmrBldFY9TYQPBw XQZA== X-Gm-Message-State: AIkVDXLwGvE7b6CbNiTnGlWJUUUfx7Z+wMY/vWCV9rpucBqpbDJI9SbKE7W4ddiYIkDrsA== X-Received: by 10.28.225.138 with SMTP id y132mr3516795wmg.52.1482268150275; Tue, 20 Dec 2016 13:09:10 -0800 (PST) Received: from localhost.localdomain (cpc101300-bagu16-2-0-cust362.1-3.cable.virginm.net. [86.21.41.107]) by smtp.gmail.com with ESMTPSA id gj6sm27369958wjb.29.2016.12.20.13.09.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Dec 2016 13:09:09 -0800 (PST) From: Sudip Mukherjee To: Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, Sudip Mukherjee Subject: [PATCH] nfc: fdp: fix NULL pointer dereference Date: Tue, 20 Dec 2016 21:09:04 +0000 Message-Id: <1482268144-14028-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-Virus-Scanned: ClamAV using ClamSMTP We are checking phy after dereferencing it. We can print the debug information after checking it. If phy is NULL then we will get a good stack trace to tell us that we are in this irq handler. Signed-off-by: Sudip Mukherjee --- drivers/nfc/fdp/i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c index 5e797d5..712936f 100644 --- a/drivers/nfc/fdp/i2c.c +++ b/drivers/nfc/fdp/i2c.c @@ -210,14 +210,14 @@ static irqreturn_t fdp_nci_i2c_irq_thread_fn(int irq, void *phy_id) struct sk_buff *skb; int r; - client = phy->i2c_dev; - dev_dbg(&client->dev, "%s\n", __func__); - if (!phy || irq != phy->i2c_dev->irq) { WARN_ON_ONCE(1); return IRQ_NONE; } + client = phy->i2c_dev; + dev_dbg(&client->dev, "%s\n", __func__); + r = fdp_nci_i2c_read(phy, &skb); if (r == -EREMOTEIO)