app/testpmd: do not use a possibly NULL Pointer

Message ID 20210524090144.16908-1-thierry.herbelot@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series app/testpmd: do not use a possibly NULL Pointer |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Thierry Herbelot May 24, 2021, 9:01 a.m. UTC
  Use out only after it was checked not to be NULL.

Fixes: 4d07cbefe3ba0 ("app/testpmd: add commands for conntrack")
Cc: stable@dpdk.org
Cc: Ori Kam <orika@nvidia.com>

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 app/test-pmd/cmdline_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Bing Zhao May 25, 2021, 2:01 p.m. UTC | #1
Hi Thierry,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Thierry Herbelot
> Sent: Monday, May 24, 2021 5:02 PM
> To: dev@dpdk.org
> Cc: Thierry Herbelot <thierry.herbelot@6wind.com>; NBU-Contact-
> Thomas Monjalon <thomas@monjalon.net>; stable@dpdk.org; Ori Kam
> <orika@nvidia.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: do not use a possibly NULL
> Pointer
> 
> External email: Use caution opening links or attachments
> 
> 
> Use out only after it was checked not to be NULL.
> 
> Fixes: 4d07cbefe3ba0 ("app/testpmd: add commands for conntrack")
> Cc: stable@dpdk.org
> Cc: Ori Kam <orika@nvidia.com>
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
>  app/test-pmd/cmdline_flow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-
> pmd/cmdline_flow.c
> index 1c587bb7b803..7645b3cc90a1 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -6631,10 +6631,10 @@ parse_vc_action_conntrack_update(struct
> context *ctx, const struct token *token,
>         /* Token name must match. */
>         if (parse_default(ctx, token, str, len, NULL, 0) < 0)
>                 return -1;
> -       ct_modify = (struct rte_flow_modify_conntrack *)out-
> >args.vc.data;
>         /* Nothing else to do if there is no buffer. */
>         if (!out)
>                 return len;
> +       ct_modify = (struct rte_flow_modify_conntrack *)out-
> >args.vc.data;

Thanks.
Will there be a segment fault if an auto-completion is done by using "tab"?

>         if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
>                 ct_modify->new_ct.is_original_dir =
>                                 conntrack_context.is_original_dir;
> --
> 2.29.2

Reviewed-by: Bing Zhao <bingz@nvidia.com>
  
Singh, Aman Deep June 10, 2021, 5:28 p.m. UTC | #2
On 5/24/2021 2:31 PM, Thierry Herbelot wrote:
> Use out only after it was checked not to be NULL.
>
> Fixes: 4d07cbefe3ba0 ("app/testpmd: add commands for conntrack")
> Cc: stable@dpdk.org
> Cc: Ori Kam <orika@nvidia.com>
>
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
> Acked-by: Aman Deep Singh <aman.deep.singh@intel.com 
> <mailto:aman.deep.singh@intel.com>>
  
Andrew Rybchenko June 29, 2021, 8:26 a.m. UTC | #3
On 6/10/21 8:28 PM, Singh, Aman Deep wrote:
> 
> On 5/24/2021 2:31 PM, Thierry Herbelot wrote:
>> Use out only after it was checked not to be NULL.
>>
>> Fixes: 4d07cbefe3ba0 ("app/testpmd: add commands for conntrack")
>> Cc: stable@dpdk.org
>> Cc: Ori Kam <orika@nvidia.com>
>>
>> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
>> ---

Acked-by: Aman Deep Singh <aman.deep.singh@intel.com>

Applied, thanks.
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 1c587bb7b803..7645b3cc90a1 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -6631,10 +6631,10 @@  parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
 	/* Token name must match. */
 	if (parse_default(ctx, token, str, len, NULL, 0) < 0)
 		return -1;
-	ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
 	/* Nothing else to do if there is no buffer. */
 	if (!out)
 		return len;
+	ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
 	if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
 		ct_modify->new_ct.is_original_dir =
 				conntrack_context.is_original_dir;