Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFC: digital: Randomize poll cycles

This change adds some entropy to polling cycles, choosing the next
polling rf technology randomly. This reflects the change done in the
pn533 driver, avoiding possible infinite loop for devices that export 2
targets on 2 different modulations. If the first target is not
readable, we will stay in an error loop for ever.

Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Thierry Escande and committed by
Samuel Ortiz
9dc33705 00e625df

+4 -2
+4 -2
net/nfc/digital_core.c
··· 386 386 387 387 void digital_poll_next_tech(struct nfc_digital_dev *ddev) 388 388 { 389 + u8 rand_mod; 390 + 389 391 digital_switch_rf(ddev, 0); 390 392 391 393 mutex_lock(&ddev->poll_lock); ··· 397 395 return; 398 396 } 399 397 400 - ddev->poll_tech_index = (ddev->poll_tech_index + 1) % 401 - ddev->poll_tech_count; 398 + get_random_bytes(&rand_mod, sizeof(rand_mod)); 399 + ddev->poll_tech_index = rand_mod % ddev->poll_tech_count; 402 400 403 401 mutex_unlock(&ddev->poll_lock); 404 402