summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorGustavo A. R. Silva <garsilva@embeddedor.com>2017-05-30 22:43:07 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2017-06-23 00:34:56 +0200
commit6f874bafacf053b87887f4149fc117e2b1096138 (patch)
tree741c3b62f5a3001684a941948966e3890fcefe54 /drivers/nfc
parentnfc: nci: remove unnecessary null check (diff)
downloadlinux-6f874bafacf053b87887f4149fc117e2b1096138.tar.xz
linux-6f874bafacf053b87887f4149fc117e2b1096138.zip
NFC: add NULL checks to avoid potential NULL pointer dereference
NULL checks at line 457: if (!link0 || !link1) {, implies that both pointers link0 and link1 might be NULL. Function nfcsim_link_free() dereference pointers link0 and link1. Add NULL checks before calling nfcsim_link_free() to avoid a potential NULL pointer dereference. Addresses-Coverity-ID: 1364857 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/nfcsim.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index a466e7978466..33449820e754 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -482,8 +482,10 @@ static int __init nfcsim_init(void)
exit_err:
pr_err("Failed to initialize nfcsim driver (%d)\n", rc);
- nfcsim_link_free(link0);
- nfcsim_link_free(link1);
+ if (link0)
+ nfcsim_link_free(link0);
+ if (link1)
+ nfcsim_link_free(link1);
return rc;
}