bman_release() computed i = num - 1 before the num == 0 bounds check,
which only exists under RTE_LIBRTE_DPAA_HWDEBUG. With that debug flag
disabled and num == 0, i wraps to UINT32_MAX, and the subsequent
'if (i)' guard is then always taken regardless of num, relying on the
for loop's own bound to do nothing. The indirection added no value and
obscured the num == 0 handling.
Drop the i = num - 1 initializer and the if (i) wrapper, relying
solely on the for (i = 1; i < num; i++) loop condition, matching the
simpler pattern already used in bman_release_fast().
Fixes: f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")
Signed-off-by: Gagandeep Singh <[email protected]>
---
drivers/bus/dpaa/base/qbman/bman.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/dpaa/base/qbman/bman.c
b/drivers/bus/dpaa/base/qbman/bman.c
index 76e612662f..31114b2d57 100644
--- a/drivers/bus/dpaa/base/qbman/bman.c
+++ b/drivers/bus/dpaa/base/qbman/bman.c
@@ -304,7 +304,7 @@ int bman_release(struct bman_pool *pool, const struct
bm_buffer *bufs, u8 num,
{
struct bman_portal *p;
struct bm_rcr_entry *r;
- u32 i = num - 1;
+ u32 i;
u8 avail;
#ifdef RTE_LIBRTE_DPAA_HWDEBUG
@@ -329,11 +329,9 @@ int bman_release(struct bman_pool *pool, const struct
bm_buffer *bufs, u8 num,
r->bufs[0].opaque =
cpu_to_be64(((u64)pool->params.bpid << 48) |
(bufs[0].opaque & MAX_U48));
- if (i) {
- for (i = 1; i < num; i++)
- r->bufs[i].opaque =
- cpu_to_be64(bufs[i].opaque & MAX_U48);
- }
+ for (i = 1; i < num; i++)
+ r->bufs[i].opaque =
+ cpu_to_be64(bufs[i].opaque & MAX_U48);
bm_rcr_pvb_commit(&p->p, BM_RCR_VERB_CMD_BPID_SINGLE |
(num & BM_RCR_VERB_BUFCOUNT_MASK));
--
2.25.1