From patchwork Thu Dec 15 22:30:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Lansberry X-Patchwork-Id: 9477053 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 3D15C60571 for ; Thu, 15 Dec 2016 22:31:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FF5B25F3E for ; Thu, 15 Dec 2016 22:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 249342886B; Thu, 15 Dec 2016 22:31:48 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable 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 C867D25F3E for ; Thu, 15 Dec 2016 22:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756671AbcLOWbS (ORCPT ); Thu, 15 Dec 2016 17:31:18 -0500 Received: from mail-qk0-f175.google.com ([209.85.220.175]:36109 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755660AbcLOWa5 (ORCPT ); Thu, 15 Dec 2016 17:30:57 -0500 Received: by mail-qk0-f175.google.com with SMTP id n21so72961380qka.3 for ; Thu, 15 Dec 2016 14:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kuvee-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UBbRelrXdqaGXpTxMC8CXWIBxPJHgLJ2Dw1aKryZgCM=; b=C8jTfHCB68hdFtILesxgpL4lL3W7iUCc85bfr8PzKCi258sJDwpzNJWp1p/+4Iq1q7 i902RfrXA6T+0lQ2yU17DnYj9QRqtBzHRmPvZeEpYn0rN5u3jC/Yy83YWDLLAFT3Bi4E nhZ0F4ZztOUzU1GpK1ouv0t8n8vtr4lpjJiOK6D3p+66L20peZDP7y79aakqPEL6lG1A Au9bN5DcXTyzXB7+9Msig1SQmwf591ympitmORjJGE74qkJMgbHpivaupi13b04KnhSK hYsOL6OtpOdicyMC3kHOlwg9iSrUYn5llVbL4UV4iwr2kceCCv20D/elisY2rqRTWzhM h2iQ== 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:in-reply-to :references; bh=UBbRelrXdqaGXpTxMC8CXWIBxPJHgLJ2Dw1aKryZgCM=; b=txCZ5OdGHoim7S+MCMZZ2f90Hk6XjbWKdSxbAHQDHQT53BBuiiQML8bY5n25S1sbOv i2fIwd+HvR43QpjG/oHZtjuvFB+AdR5keSL8lYP8JYqDYrNJhOAx86aUThDWFxLRU4cT OduId3bXEJVGLPBNN42fMhM9GHhbnTdI5ChFuGSREYe92Wxeh5frWlQ0ApccM5wJpDKE UB0toWxp3tKjz2hI/pleNv8ucJlRyU1JuKcVGd0gL49p7Im9b/gS0d0fTw4jz+EP7rD4 TFlEAYVvyTz/JcYldtj97Kcujircaoh54MwbbZ+1hmx/y6JXjzEVmpo9Qf/fDs/N5ZmP b8ng== X-Gm-Message-State: AIkVDXJbLiBXc4tHVzKQVHVxOAAZVsNOo6leEn2fJbEPljsLIiyCuLpNuLqxHD9CGLEVEw== X-Received: by 10.55.143.195 with SMTP id r186mr2975826qkd.152.1481841056212; Thu, 15 Dec 2016 14:30:56 -0800 (PST) Received: from localhost.localdomain (c-73-119-141-105.hsd1.ma.comcast.net. [73.119.141.105]) by smtp.googlemail.com with ESMTPSA id f36sm2166515qkf.43.2016.12.15.14.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Dec 2016 14:30:55 -0800 (PST) From: Geoff Lansberry X-Google-Original-From: Geoff Lansberry To: linux-wireless@vger.kernel.org Cc: lauro.venancio@openbossa.org, aloisio.almeida@openbossa.org, sameo@linux.intel.com, robh+dt@kernel.org, mark.rutland@arm.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, mgreer@animalcreek.com, justin@kuvee.com, Jaret Cantu , Geoff Lansberry Subject: [PATCH 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel Date: Thu, 15 Dec 2016 17:30:44 -0500 Message-Id: <1481841044-4314-3-git-send-email-glansberry@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481841044-4314-1-git-send-email-glansberry@gmail.com> References: <1481841044-4314-1-git-send-email-glansberry@gmail.com> 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 From: Jaret Cantu Repeated polling attempts cause a NULL dereference error to occur. This is because the curent state of the trf7970a is reading but a request has been made to send a command. The solution is to properly kill the waiting reading (workqueue) before failing on the send. --- drivers/nfc/trf7970a.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index b4c37ab..f96a321 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -1493,6 +1493,10 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev, (trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) { dev_err(trf->dev, "%s - Bogus state: %d\n", __func__, trf->state); + if (trf->state == TRF7970A_ST_WAIT_FOR_RX_DATA || + trf->state == TRF7970A_ST_WAIT_FOR_RX_DATA_CONT) + trf->ignore_timeout = + !cancel_delayed_work(&trf->timeout_work); ret = -EIO; goto out_err; }