DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/nfp: fix misuse of function return values
@ 2025-01-22  1:33 Chaoyong He
  0 siblings, 0 replies; only message in thread
From: Chaoyong He @ 2025-01-22  1:33 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Zerun Fu, chaoyong.he, stable, Long Wu, Peng Zhang

From: Zerun Fu <zerun.fu@corigine.com>

The 'nfp_ct_offload_add()' return 0 means the result is right
while return negative number means the wrong result.

The caller assigns the 'int' variable to the 'bool' variable.
So the negative number will be transform to 'true'. This will
cause an error because 'true' will be regard as no problem.

Fixes: b4ae16eae01c ("net/nfp: support to add and delete flows to firmware")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_conntrack.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_conntrack.c b/drivers/net/nfp/flower/nfp_conntrack.c
index 0b21e4ee5b..439a1a1b0e 100644
--- a/drivers/net/nfp/flower/nfp_conntrack.c
+++ b/drivers/net/nfp/flower/nfp_conntrack.c
@@ -1440,6 +1440,7 @@ nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze,
 		struct nfp_ct_flow_entry *pre_ct_entry,
 		struct nfp_ct_flow_entry *post_ct_entry)
 {
+	int err;
 	bool ret;
 	uint64_t new_cookie[2];
 	uint8_t cnt_same_item = 0;
@@ -1508,9 +1509,10 @@ nfp_ct_do_flow_merge(struct nfp_ct_zone_entry *ze,
 	}
 
 	/* Send to firmware */
-	ret = nfp_ct_offload_add(pre_ct_entry->dev, merge_entry);
-	if (ret != 0) {
+	err = nfp_ct_offload_add(pre_ct_entry->dev, merge_entry);
+	if (err != 0) {
 		PMD_DRV_LOG(ERR, "Send the merged flow to firmware failed.");
+		ret = false;
 		goto merge_table_del;
 	}
 
-- 
2.43.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-22  1:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-22  1:33 [PATCH] net/nfp: fix misuse of function return values Chaoyong He

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).