Skip to contentSkip to conversation

lib: add warning for NULL pointer

PATCH In review Qiming Yang 4 participants 5 messages Dec 5, 2018 – Jan 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: add warning for NULL pointer

May return NULL when manage tries for packet in acl library. So this patch added warning for the NULL pointer return.

Fixes 074f54ad03ee ("acl: fix build and runtime for default target")
---
 lib/librte_acl/acl_run.h | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_acl/acl_run.h +3 -0
index bf7842d..6c718c0 100644
@@ -143,6 +143,9 @@ acl_start_next_trie(struct acl_flow_data *flows, struct parms *parms, int n,
 				flows->num_packets * flows->categories);
 		}
 
+		if (flows->last_cmplt == NULL)
+			RTE_LOG(WARNING, MALLOC, "packet tries allocate failed");
+
 		/* set completion parameters and starting index for this slot */
 		parms[n].cmplt = flows->last_cmplt;
 		transition =
Signature · 1 line
2.9.5
#1 lore raw

Hi,

Should not the warning be stated for ' alloc_completion' failure

Snipped

Quoted 6 lines
lib/librte_acl/acl_run.h +2 -0
 				flows->num_packets * flows->categories);
 		}
 
+		if (flows->last_cmplt == NULL)
+			RTE_LOG(WARNING, MALLOC, "packet tries allocate

failed");

Why is that we want to try this outside block?

Quoted 6 lines
lib/librte_acl/acl_run.h +1 -1
+
 		/* set completion parameters and starting index for this slot */
 		parms[n].cmplt = flows->last_cmplt;
 		transition =
--

2.9.5

#2 lore raw

Do you plan to check for all iteration for ' flows->last_cmplt ' is successful?

Quoted 28 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Varghese, Vipin
Sent: Wednesday, December 5, 2018 10:07 AM
To: Yang, Qiming <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] lib: add warning for NULL pointer

Hi,

Should not the warning be stated for ' alloc_completion' failure

Snipped

Quoted 6 lines
lib/librte_acl/acl_run.h +2 -0
 				flows->num_packets * flows->categories);
 		}
 
+		if (flows->last_cmplt == NULL)
+			RTE_LOG(WARNING, MALLOC, "packet tries allocate

failed");

Why is that we want to try this outside block?

Quoted 6 lines
lib/librte_acl/acl_run.h +1 -1
+
 		/* set completion parameters and starting index for this slot */
 		parms[n].cmplt = flows->last_cmplt;
 		transition =
--

2.9.5

#3 lore raw
In reply to Qiming Yang
Quoted 16 lines · On Wed, 5 Dec 2018 19:55:31 +0800 Qiming Yang <[email protected]> wrote:

May return NULL when manage tries for packet in acl library. So this patch added warning for the NULL pointer return.

Fixes 074f54ad03ee ("acl: fix build and runtime for default target")
---
 lib/librte_acl/acl_run.h | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_acl/acl_run.h +0 -0
index bf7842d..6c718c0 100644

lib/librte_acl/acl_run.h acl_start_next_trie(struct acl_flow_data *flows, struct parms *parms, int n, · line 151

Quoted 9 lines
lib/librte_acl/acl_run.h +3 -0
@@ -143,6 +143,9 @@ acl_start_next_trie(struct acl_flow_data *flows, struct parms *parms, int n,
 				flows->num_packets * flows->categories);
 		}
 
+		if (flows->last_cmplt == NULL)
+			RTE_LOG(WARNING, MALLOC, "packet tries allocate failed");
+
 		/* set completion parameters and starting index for this slot */
 		parms[n].cmplt = flows->last_cmplt;
 		transition =

It would be better to return -ENOMEM and let caller handle the error.

#4 lore raw
In reply to Qiming Yang
Quoted 25 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Qiming Yang
Sent: Wednesday, December 5, 2018 11:56 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH] lib: add warning for NULL pointer

May return NULL when manage tries for packet in acl library. So this patch added warning for the NULL pointer return.

Fixes 074f54ad03ee ("acl: fix build and runtime for default target")
---
 lib/librte_acl/acl_run.h | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_acl/acl_run.h +0 -0
index bf7842d..6c718c0 100644

lib/librte_acl/acl_run.h acl_start_next_trie(struct acl_flow_data *flows, struct parms *parms, int n, · line 148

Quoted 6 lines
lib/librte_acl/acl_run.h +3 -0
@@ -143,6 +143,9 @@ acl_start_next_trie(struct acl_flow_data *flows, struct parms *parms, int n,
 				flows->num_packets * flows->categories);
 		}
 
+		if (flows->last_cmplt == NULL)
+			RTE_LOG(WARNING, MALLOC, "packet tries allocate failed");
+

alloc_completion() should never retrun NULL (unless something is totally broken). So no need to handle such situation. If you desire - feel free to add RTE_ASSERT(flows->last_cmplt != NULL) here.
Konstantin

Quoted 5 lines
lib/librte_acl/acl_run.h +0 -1
 		/* set completion parameters and starting index for this slot */
 		parms[n].cmplt = flows->last_cmplt;
 		transition =
--

2.9.5