From: Gustavo A. R. Silva <hidden> Date: 2017-06-12 22:02:35
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 <redacted>
---
net/nfc/nci/core.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
On Mon, Jun 12, 2017 at 05:02:23PM -0500, Gustavo A. R. Silva wrote:
quoted hunk
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 <redacted>
---
net/nfc/nci/core.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -70,14 +70,13 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type,structnci_conn_info*conn_info;list_for_each_entry(conn_info,&ndev->conn_info_list,list){
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL. Plus, it is dereferenced there as well.
The check is unnecessary.
Guenter
quoted hunk
- 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; } }
From: Gustavo A. R. Silva <hidden> Date: 2017-06-12 22:53:16
Hi Guenter,
Please, see my comments below
Quoting Guenter Roeck [off-list ref]:
On Mon, Jun 12, 2017 at 05:02:23PM -0500, Gustavo A. R. Silva wrote:
quoted
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 <redacted>
---
net/nfc/nci/core.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -70,14 +70,13 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type,structnci_conn_info*conn_info;list_for_each_entry(conn_info,&ndev->conn_info_list,list){
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL. Plus, it is dereferenced there as well.
The check is unnecessary.
Thanks for clarifying.
Guenter
quoted
- 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) {
So, this NULL check could be removed as it seems it is not useful at all ?
On 06/12/2017 03:28 PM, Gustavo A. R. Silva wrote:
Hi Guenter,
Please, see my comments below
Quoting Guenter Roeck [off-list ref]:
quoted
On Mon, Jun 12, 2017 at 05:02:23PM -0500, Gustavo A. R. Silva wrote:
quoted
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 <redacted>
---
net/nfc/nci/core.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -70,14 +70,13 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8 dest_type,structnci_conn_info*conn_info;list_for_each_entry(conn_info,&ndev->conn_info_list,list){
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL. Plus, it is dereferenced there as well.
The check is unnecessary.
Thanks for clarifying.
quoted
Guenter
quoted
- 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) {
So, this NULL check could be removed as it seems it is not useful at all ?
From: Gustavo A. R. Silva <hidden> Date: 2017-06-13 16:37:24
Remove unnecessary NULL check for pointer conn_info.
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL.
Addresses-Coverity-ID: 1362349
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Gustavo A. R. Silva <redacted>
---
net/nfc/nci/core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
On Tue, Jun 13, 2017 at 11:37:18AM -0500, Gustavo A. R. Silva wrote:
Remove unnecessary NULL check for pointer conn_info.
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL.
Addresses-Coverity-ID: 1362349
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Gustavo A. R. Silva <redacted>
From: Samuel Ortiz <hidden> Date: 2017-06-22 22:35:34
Hi Gustavo,
On Tue, Jun 13, 2017 at 11:37:18AM -0500, Gustavo A. R. Silva wrote:
Remove unnecessary NULL check for pointer conn_info.
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL.
Addresses-Coverity-ID: 1362349
Cc: Guenter Roeck <redacted>
Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
---
net/nfc/nci/core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
From: Gustavo A. R. Silva <hidden> Date: 2017-06-23 01:46:13
Hi Samuel,
Quoting Samuel Ortiz [off-list ref]:
Hi Gustavo,
On Tue, Jun 13, 2017 at 11:37:18AM -0500, Gustavo A. R. Silva wrote:
quoted
Remove unnecessary NULL check for pointer conn_info.
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL.
Addresses-Coverity-ID: 1362349
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Gustavo A. R. Silva <redacted>
---
net/nfc/nci/core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)