]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFC: add NULL checks to avoid potential NULL pointer dereference
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Tue, 30 May 2017 20:43:07 +0000 (15:43 -0500)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 22 Jun 2017 22:34:56 +0000 (00:34 +0200)
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>
drivers/nfc/nfcsim.c

index a466e79784668ef44955aad0d2b61cc9e1a5b3b6..33449820e75422e70753d767c5b95a061fdfe19a 100644 (file)
@@ -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;
 }