Patchwork [dpdk-dev] lib: add warning for NULL pointer

login
register
mail settings
Submitter Qiming Yang
Date Dec. 5, 2018, 11:55 a.m.
Message ID <20181205115531.17073-1-qiming.yang@intel.com>
Download mbox | patch
Permalink /patch/672523/
State New
Headers show

Comments

Varghese, Vipin - Dec. 5, 2018, 4:37 a.m.
Hi,

Should not the warning be stated for ' alloc_completion' failure

Snipped

>  				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?

> +
>  		/* set completion parameters and starting index for this slot */
>  		parms[n].cmplt = flows->last_cmplt;
>  		transition =
> --
> 2.9.5
Varghese, Vipin - Dec. 5, 2018, 5:15 a.m.
Do you plan to check for all iteration for ' flows->last_cmplt ' is successful?

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Varghese, Vipin
> Sent: Wednesday, December 5, 2018 10:07 AM
> To: Yang, Qiming <qiming.yang@intel.com>; dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] lib: add warning for NULL pointer
> 
> Hi,
> 
> Should not the warning be stated for ' alloc_completion' failure
> 
> Snipped
> 
> >  				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?
> 
> > +
> >  		/* set completion parameters and starting index for this slot */
> >  		parms[n].cmplt = flows->last_cmplt;
> >  		transition =
> > --
> > 2.9.5
Qiming Yang - Dec. 5, 2018, 11:55 a.m.
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")
Cc: stable@dpdk.org

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
---
 lib/librte_acl/acl_run.h | 3 +++
 1 file changed, 3 insertions(+)
Stephen Hemminger - Dec. 5, 2018, 5:06 p.m.
On Wed,  5 Dec 2018 19:55:31 +0800
Qiming Yang <qiming.yang@intel.com> 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")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Qiming Yang <qiming.yang@intel.com>
> ---
>  lib/librte_acl/acl_run.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/librte_acl/acl_run.h b/lib/librte_acl/acl_run.h
> index bf7842d..6c718c0 100644
> --- a/lib/librte_acl/acl_run.h
> +++ b/lib/librte_acl/acl_run.h
> @@ -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.

Patch

diff --git a/lib/librte_acl/acl_run.h b/lib/librte_acl/acl_run.h
index bf7842d..6c718c0 100644
--- a/lib/librte_acl/acl_run.h
+++ b/lib/librte_acl/acl_run.h
@@ -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 =