NFC: pn533: Fix div by zero while stopping polling
authorWaldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Wed, 3 Apr 2013 06:02:00 +0000 (08:02 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 11 Apr 2013 14:29:00 +0000 (16:29 +0200)
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] [<c001b38c>] (unwind_backtrace+0x0/0xf0)
[345.965698] [<c0260e78>] (Ldiv0+0x8/0x10)
[345.974060] [<c0260e60>] (__aeabi_idivmod+0x8/0x18)
[345.983978] [<c02e0064>] (pn533_poll_complete+0x3c0/0x500)
[345.994903] [<c02df690>] (pn533_send_async_complete+0x7c/0xc0)
[346.005828] [<c02e028c>] (pn533_wq_cmd_complete+0x1c/0x34)
[346.016113] [<c005d134>] (process_one_work+0x1ac/0x57c)
[346.025848] [<c005d85c>] (worker_thread+0x168/0x42c)
[346.034576] [<c00620c0>] (kthread+0xa4/0xb0)

Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn533.c

index 8ee032d3faa0009c4dd2dfceec7dbdcce313bf08..c20778a56f4f6441bf3863c4d16ca2c3a5301fe4 100644 (file)
@@ -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);