DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Srikanth Yalavarthi <syalavarthi@marvell.com>
Subject: [PATCH 2/4] ml/cnkx: remove unnecessary null checks
Date: Wed, 22 Mar 2023 18:04:26 -0700	[thread overview]
Message-ID: <20230323010428.64020-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20230323010428.64020-1-stephen@networkplumber.org>

These are places where null check is not necessary before
calling free.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/ml/cnxk/cn10k_ml_dev.c |  9 +++------
 drivers/ml/cnxk/cn10k_ml_ops.c | 12 ++++--------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/ml/cnxk/cn10k_ml_dev.c b/drivers/ml/cnxk/cn10k_ml_dev.c
index bba3c9022e6b..983138a7f237 100644
--- a/drivers/ml/cnxk/cn10k_ml_dev.c
+++ b/drivers/ml/cnxk/cn10k_ml_dev.c
@@ -319,8 +319,7 @@ cn10k_mldev_parse_devargs(struct rte_devargs *devargs, struct cn10k_ml_dev *mlde
 	plt_info("ML: %s = %d", CN10K_ML_OCM_PAGE_SIZE, mldev->ocm_page_size);
 
 exit:
-	if (kvlist)
-		rte_kvargs_free(kvlist);
+	rte_kvargs_free(kvlist);
 
 	return ret;
 }
@@ -795,8 +794,7 @@ cn10k_ml_fw_load(struct cn10k_ml_dev *mldev)
 	mz = plt_memzone_reserve_aligned(FW_MEMZONE_NAME, mz_size, 0, ML_CN10K_ALIGN_SIZE);
 	if (mz == NULL) {
 		plt_err("plt_memzone_reserve failed : %s", FW_MEMZONE_NAME);
-		if (fw_buffer != NULL)
-			free(fw_buffer);
+		free(fw_buffer);
 		return -ENOMEM;
 	}
 	fw->req = mz->addr;
@@ -813,8 +811,7 @@ cn10k_ml_fw_load(struct cn10k_ml_dev *mldev)
 	if (roc_env_is_emulator() || roc_env_is_hw()) {
 		fw->data = PLT_PTR_ADD(mz->addr, sizeof(struct cn10k_ml_req));
 		ret = cn10k_ml_fw_load_cn10ka(fw, fw_buffer, fw_size);
-		if (fw_buffer != NULL)
-			free(fw_buffer);
+		free(fw_buffer);
 	} else if (roc_env_is_asim()) {
 		fw->data = NULL;
 		ret = cn10k_ml_fw_load_asim(fw);
diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c
index 4df2ca0e8c26..b5eaa24e831c 100644
--- a/drivers/ml/cnxk/cn10k_ml_ops.c
+++ b/drivers/ml/cnxk/cn10k_ml_ops.c
@@ -845,11 +845,9 @@ cn10k_ml_dev_configure(struct rte_ml_dev *dev, const struct rte_ml_dev_config *c
 	return 0;
 
 error:
-	if (dev->data->queue_pairs != NULL)
-		rte_free(dev->data->queue_pairs);
+	rte_free(dev->data->queue_pairs);
 
-	if (dev->data->models != NULL)
-		rte_free(dev->data->models);
+	rte_free(dev->data->models);
 
 	return ret;
 }
@@ -887,8 +885,7 @@ cn10k_ml_dev_close(struct rte_ml_dev *dev)
 		}
 	}
 
-	if (dev->data->models)
-		rte_free(dev->data->models);
+	rte_free(dev->data->models);
 
 	/* Destroy all queue pairs */
 	for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) {
@@ -900,8 +897,7 @@ cn10k_ml_dev_close(struct rte_ml_dev *dev)
 		}
 	}
 
-	if (dev->data->queue_pairs)
-		rte_free(dev->data->queue_pairs);
+	rte_free(dev->data->queue_pairs);
 
 	/* Unload firmware */
 	cn10k_ml_fw_unload(mldev);
-- 
2.39.2


  parent reply	other threads:[~2023-03-23  1:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  1:04 [PATCH 0/4] Remove unnecessary null free checks Stephen Hemminger
2023-03-23  1:04 ` [PATCH 1/4] mldev: remove " Stephen Hemminger
2023-03-23  4:06   ` [EXT] " Srikanth Yalavarthi
2023-03-23  1:04 ` Stephen Hemminger [this message]
2023-03-23  4:14   ` [EXT] [PATCH 2/4] ml/cnkx: remove unnecessary null checks Srikanth Yalavarthi
2023-03-23  1:04 ` [PATCH 3/4] graph: remove unnicessary " Stephen Hemminger
2023-03-23  1:04 ` [PATCH 4/4] examples/fips_validation: remove unneeded " Stephen Hemminger
2023-03-23  9:33 ` [PATCH 0/4] Remove unnecessary null free checks Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230323010428.64020-3-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=syalavarthi@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).