From patchwork Tue Dec 20 16:10:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Lansberry X-Patchwork-Id: 9481779 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 D9A66606DB for ; Tue, 20 Dec 2016 16:15:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8C13223A6 for ; Tue, 20 Dec 2016 16:15:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBFF628410; Tue, 20 Dec 2016 16:15:26 +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 7DF54223A6 for ; Tue, 20 Dec 2016 16:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934457AbcLTQPL (ORCPT ); Tue, 20 Dec 2016 11:15:11 -0500 Received: from mail-qt0-f173.google.com ([209.85.216.173]:36393 "EHLO mail-qt0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763607AbcLTQLM (ORCPT ); Tue, 20 Dec 2016 11:11:12 -0500 Received: by mail-qt0-f173.google.com with SMTP id w33so180820733qtc.3 for ; Tue, 20 Dec 2016 08:11:11 -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=CiJ538aWBsGLpiBFsQdl904ziTV0w5Gjz7zRhuYA5qo=; b=E8w91X3YTSnBwhwWmd3JmhBKlnr2s6/So3uUuVLV7JPOMTAN/xxWfuc7TTJWbT3kaJ +iKtv4AUu0VbswRp2AylO9KPR5MPicyIds8/hQidU8FNw0TLUd6ANWZVZ6qyBmKU2f7Z 8PcTwb2cPmPoquFvOzcDSuUTAsQAJUXPwSfShtvWmu7eB0N0yBBQ58RiVLsD2eUyX33d 8nkdn2Wzytc/H7mtZNH3JfAYXqVIs8fxxnqAw9RxuAuwGF8hmS2yz4nvSVsNydPFcrl+ gLOjUXHWTwM6hi/T14y/NqYAX/FUxT7VPFNJdKbhkX/J2hrJGrHBlns9nXrz3WIWLZed +pGQ== 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=CiJ538aWBsGLpiBFsQdl904ziTV0w5Gjz7zRhuYA5qo=; b=qjUhbWl2NrzLlia/3GxjwoO35mxomI+m9TXS3KgZHdZ64tcGuC+Tlu06Po1yloRH7I u6XLQ+GYoZ5euThfD5YHuxU1MCBEJKdLTmlpWkO9X8mevONnzm7jxU/lKm4JJ9xX1wWh fBz4YuIz+SHC3We//CdDy5TJuNTWjSNdvLFmbDm8y/mIQKuoFRQZpBu1UPQkjBAnVx2O dS4Ep95wDPLKkws2tm5LXSuv7iURJF7QsIitCWik1FZwcL90xgcS3Uqky42N6c/45a25 bmoBHPDJPH0RcdrJrUOFTtvD422rWW9a3vFZMt5vAAk8JdqNAztsX9cQlk2AHgQXxxDL 8lFg== X-Gm-Message-State: AIkVDXItBok+3E/VVWTmHhkdVxbgihQRZgOzuo4EaosT6c4r/YOCYh//NFW27XXuO70Gag== X-Received: by 10.200.41.9 with SMTP id y9mr130669qty.26.1482250270917; Tue, 20 Dec 2016 08:11:10 -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 u7sm13370785qkh.2.2016.12.20.08.11.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Dec 2016 08:11:10 -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 2/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel Date: Tue, 20 Dec 2016 11:10:47 -0500 Message-Id: <1482250250-4192-4-git-send-email-glansberry@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482250250-4192-1-git-send-email-glansberry@gmail.com> References: <1482250250-4192-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 state of the trf7970a is currently reading but another request has been made to send a command before it has finished. 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 94c31f8..e9e93ea 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -1496,6 +1496,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; }