NFC: avoid freeing unallocated memory
Issue: In function ese_cold_reset_ioctl, kfree is getting call for nfc_dev->cold_reset.cmd_buf in case of early failure in the function. Fix: Add check NULL check before calling kfree Change-Id: Ic3e86494f65330ff58a0deb394b3a654f0a395db Signed-off-by: Om Prakash Singh <quic_omprsing@quicinc.com> Signed-off-by: Udit Tiwari <quic_utiwari@quicinc.com>
This commit is contained in:
parent
fdcb27d4e7
commit
42ca8887f6
@ -335,10 +335,14 @@ int ese_cold_reset_ioctl(struct nfc_dev *nfc_dev, unsigned long arg)
|
||||
ret = nfc_dev->cold_reset.status;
|
||||
|
||||
err:
|
||||
kfree(nfc_dev->cold_reset.cmd_buf);
|
||||
nfc_dev->cold_reset.cmd_buf = NULL;
|
||||
kfree(cold_reset_arg);
|
||||
cold_reset_arg = NULL;
|
||||
if (nfc_dev->cold_reset.cmd_buf != NULL) {
|
||||
kfree(nfc_dev->cold_reset.cmd_buf);
|
||||
nfc_dev->cold_reset.cmd_buf = NULL;
|
||||
}
|
||||
if (cold_reset_arg != NULL) {
|
||||
kfree(cold_reset_arg);
|
||||
cold_reset_arg = NULL;
|
||||
}
|
||||
|
||||
mutex_unlock(&nfc_dev->write_mutex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user