فهرست منبع

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 <[email protected]>
Om Prakash Singh 2 سال پیش
والد
کامیت
fe2e65e65f
1فایلهای تغییر یافته به همراه8 افزوده شده و 4 حذف شده
  1. 8 4
      nfc/ese_cold_reset.c

+ 8 - 4
nfc/ese_cold_reset.c

@@ -392,10 +392,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);