linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFC: add NULL checks to avoid potential NULL pointer dereference
@ 2017-05-30 20:43 Gustavo A. R. Silva
  2017-06-22 22:35 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30 20:43 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-wireless, linux-kernel, Gustavo A. R. Silva

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>
---
 drivers/nfc/nfcsim.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index a466e79..6e90b54 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;
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] NFC: add NULL checks to avoid potential NULL pointer dereference
  2017-05-30 20:43 [PATCH] NFC: add NULL checks to avoid potential NULL pointer dereference Gustavo A. R. Silva
@ 2017-06-22 22:35 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2017-06-22 22:35 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: linux-wireless, linux-kernel

On Tue, May 30, 2017 at 03:43:07PM -0500, Gustavo A. R. Silva wrote:
> 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>
> ---
>  drivers/nfc/nfcsim.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
Applied, thanks.

Cheers,
Samuel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-22 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30 20:43 [PATCH] NFC: add NULL checks to avoid potential NULL pointer dereference Gustavo A. R. Silva
2017-06-22 22:35 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).