From a2dfcd1ff609f5a4fd3b65774618a35c5c9f73c6 Mon Sep 17 00:00:00 2001 From: Weiguo Li Date: Thu, 24 Feb 2022 23:53:59 +0800 Subject: [PATCH] net/bnxt: fix null dereference in session cleanup 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. Fixes: a46bbb57605b ("net/bnxt: update multi device design") Cc: stable@dpdk.org Signed-off-by: Weiguo Li Reviewed-by: Ajit Khaparde --- 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; }