From: Waldemar Rymarkiewicz Date: Wed, 3 Apr 2013 06:02:00 +0000 (+0200) Subject: NFC: pn533: Fix div by zero while stopping polling X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=95cb9e10239583a8a849cdbaec689b139618319a;p=linux-beck.git NFC: pn533: Fix div by zero while stopping polling Depends on timing division by zero can happen when user stops polling. pn533_stop_poll() resets modulation counter on stop_poll, but meanwhile we get response for last poll request and try, despite of stop poll request, to schedule next modulation for polling. Log message: [345.922515] pn533 1-1.3:1.0: pn533_stop_poll [345.928314] pn533 1-1.3:1.0: pn533_send_ack [345.932769] pn533 1-1.3:1.0: Received a frame. [345.937438] PN533 RX: 00 00 ff 03 fd d5 4b 00 e0 00 [345.942840] pn533 1-1.3:1.0: pn533_poll_complete [345.947753] pn533 1-1.3:1.0: pn533_start_poll_complete [345.953186] Division by zero in kernel. [345.957244] [] (unwind_backtrace+0x0/0xf0) [345.965698] [] (Ldiv0+0x8/0x10) [345.974060] [] (__aeabi_idivmod+0x8/0x18) [345.983978] [] (pn533_poll_complete+0x3c0/0x500) [345.994903] [] (pn533_send_async_complete+0x7c/0xc0) [346.005828] [] (pn533_wq_cmd_complete+0x1c/0x34) [346.016113] [] (process_one_work+0x1ac/0x57c) [346.025848] [] (worker_thread+0x168/0x42c) [346.034576] [] (kthread+0xa4/0xb0) Signed-off-by: Waldemar Rymarkiewicz Signed-off-by: Samuel Ortiz --- diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 8ee032d3faa0..c20778a56f4f 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -1550,6 +1550,11 @@ static int pn533_poll_complete(struct pn533 *dev, void *arg, if (!rc) goto done; + if (!dev->poll_mod_count) { + nfc_dev_dbg(&dev->interface->dev, "Polling has been stoped."); + goto done; + } + pn533_poll_next_mod(dev); queue_work(dev->wq, &dev->poll_work);