Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1664263

[PATCH] nfc: nci: fix potential NULL pointer dereference

From "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Newsgroups linux.kernel
Subject [PATCH] nfc: nci: fix potential NULL pointer dereference
Date 2017-06-13 00:10 +0200
Message-ID <tRFH3-800-15@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


NULL check at line 76: if (conn_info) {, implies that pointer conn_info
might be NULL, but this pointer is being previously dereferenced,
which might cause a NULL pointer dereference.

Add NULL check before dereferencing pointer conn_info in order to
avoid a potential NULL pointer dereference.

Addresses-Coverity-ID: 1362349
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 net/nfc/nci/core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 61fff42..d2198ce 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -70,14 +70,13 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type,
 	struct nci_conn_info *conn_info;
 
 	list_for_each_entry(conn_info, &ndev->conn_info_list, list) {
-		if (conn_info->dest_type == dest_type) {
+		if (conn_info && conn_info->dest_type == dest_type) {
 			if (!params)
 				return conn_info->conn_id;
-			if (conn_info) {
-				if (params->id == conn_info->dest_params->id &&
-				    params->protocol == conn_info->dest_params->protocol)
-					return conn_info->conn_id;
-			}
+
+			if (params->id == conn_info->dest_params->id &&
+			    params->protocol == conn_info->dest_params->protocol)
+				return conn_info->conn_id;
 		}
 	}
 
-- 
2.5.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] nfc: nci: fix potential NULL pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-13 00:10 +0200
  Re: nfc: nci: fix potential NULL pointer dereference Guenter Roeck <linux@roeck-us.net> - 2017-06-13 00:30 +0200
    Re: nfc: nci: fix potential NULL pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-13 01:00 +0200
      Re: nfc: nci: fix potential NULL pointer dereference Guenter Roeck <linux@roeck-us.net> - 2017-06-13 02:40 +0200
        [PATCH] nfc: nci: remove unnecessary null check "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-13 18:40 +0200
          Re: [PATCH] nfc: nci: remove unnecessary null check Guenter Roeck <linux@roeck-us.net> - 2017-06-15 19:30 +0200

csiph-web