Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1545241

[PATCH 2/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel

From Geoff Lansberry <geoff@kuvee.com>
Newsgroups linux.kernel
Subject [PATCH 2/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel
Date 2016-12-20 17:20 +0100
Message-ID <sQviX-7Qa-53@gated-at.bofh.it> (permalink)
References <sQviW-7Qa-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Jaret Cantu <jaret.cantu@timesys.com>

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;
 	}
-- 
Signed-off-by: Geoff Lansberry <geoff@kuvee.com>

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] NFC: trf7970a: add device tree option for 27MHz clock Geoff Lansberry <geoff@kuvee.com> - 2016-12-20 17:20 +0100
  [PATCH 4/4] mod of frequency Geoff Lansberry <geoff@kuvee.com> - 2016-12-20 17:20 +0100
  [PATCH 2/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel Geoff Lansberry <geoff@kuvee.com> - 2016-12-20 17:20 +0100
  [PATCH 1/3] NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage Geoff Lansberry <geoff@kuvee.com> - 2016-12-20 17:20 +0100
  [PATCH 3/3] nfc: trf7970a: Prevent repeated polling from crashing the kernel Geoff Lansberry <geoff@kuvee.com> - 2016-12-20 17:20 +0100

csiph-web