DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/bnxt: fix a null dereference in cleanup label
@ 2022-02-24 15:53 Weiguo Li
  2022-03-07  5:14 ` Ajit Khaparde
  0 siblings, 1 reply; 2+ messages in thread
From: Weiguo Li @ 2022-02-24 15:53 UTC (permalink / raw)
  To: ajit.khaparde; +Cc: michael.wildt, dev

Fixes: a46bbb57605b4 ("net/bnxt: update multi device design")

In tf_session_create(), there is a case that with 'tfp->session' still
be NULL and run 'goto cleanup', which will leads to a null dereference
by 'tfp_free(tfp->session->core_data)' in the cleanup.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 drivers/net/bnxt/tf_core/tf_session.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index 9f849a0a76..c30c0e7029 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -230,10 +230,12 @@ tf_session_create(struct tf *tfp,
 			    "FW Session close failed, rc:%s\n",
 			    strerror(-rc));
 	}
+	if (tfp->session) {
+		tfp_free(tfp->session->core_data);
+		tfp_free(tfp->session);
+		tfp->session = NULL;
+	}
 
-	tfp_free(tfp->session->core_data);
-	tfp_free(tfp->session);
-	tfp->session = NULL;
 	return rc;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/bnxt: fix a null dereference in cleanup label
  2022-02-24 15:53 [PATCH] net/bnxt: fix a null dereference in cleanup label Weiguo Li
@ 2022-03-07  5:14 ` Ajit Khaparde
  0 siblings, 0 replies; 2+ messages in thread
From: Ajit Khaparde @ 2022-03-07  5:14 UTC (permalink / raw)
  To: Weiguo Li; +Cc: dpdk-dev

[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]

On Thu, Feb 24, 2022 at 7:54 AM Weiguo Li <liwg06@foxmail.com> wrote:
>
> Fixes: a46bbb57605b4 ("net/bnxt: update multi device design")
>
> In tf_session_create(), there is a case that with 'tfp->session' still
> be NULL and run 'goto cleanup', which will leads to a null dereference
> by 'tfp_free(tfp->session->core_data)' in the cleanup.
>
> Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Patch applied to dpdk-next-net-brcm.
Thanks

> ---
>  drivers/net/bnxt/tf_core/tf_session.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
> index 9f849a0a76..c30c0e7029 100644
> --- a/drivers/net/bnxt/tf_core/tf_session.c
> +++ b/drivers/net/bnxt/tf_core/tf_session.c
> @@ -230,10 +230,12 @@ tf_session_create(struct tf *tfp,
>                             "FW Session close failed, rc:%s\n",
>                             strerror(-rc));
>         }
> +       if (tfp->session) {
> +               tfp_free(tfp->session->core_data);
> +               tfp_free(tfp->session);
> +               tfp->session = NULL;
> +       }
>
> -       tfp_free(tfp->session->core_data);
> -       tfp_free(tfp->session);
> -       tfp->session = NULL;
>         return rc;
>  }
>
> --
> 2.25.1
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4218 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-07  5:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-24 15:53 [PATCH] net/bnxt: fix a null dereference in cleanup label Weiguo Li
2022-03-07  5:14 ` Ajit Khaparde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).