NFC: Fix to reslove the slab-out-bound issue

When received the read count from application more than MAX_NCI_BUFFER_SIZE
limiting the read count to MAX_NCI_BUFFER_SIZE.

Change-Id: Ib060b3b20fedc77a2e7a13bd1ac2b4c64da87a81
This commit is contained in:
Devendar Gali
2022-08-18 13:07:01 +05:30
bovenliggende 9beac5423e
commit 3651ea6974

Bestand weergeven

@@ -278,6 +278,9 @@ ssize_t nfc_i2c_dev_read(struct file *filp, char __user *buf, size_t count,
return -ENODEV;
}
mutex_lock(&nfc_dev->read_mutex);
if (count > MAX_NCI_BUFFER_SIZE)
count = MAX_NCI_BUFFER_SIZE;
if (filp->f_flags & O_NONBLOCK) {
ret = i2c_master_recv(nfc_dev->i2c_dev.client, nfc_dev->read_kbuf, count);
pr_debug("%s: NONBLOCK read ret = %d\n", __func__, ret);