* [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one()
@ 2022-12-15 12:30 Alexey Kodanev
2022-12-18 10:00 ` Leon Romanovsky
2022-12-27 13:49 ` Leon Romanovsky
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kodanev @ 2022-12-15 12:30 UTC (permalink / raw)
To: linux-rdma; +Cc: Alexey Kodanev
If 'qhp' is NULL then 'wq' is also NULL:
struct t4_wq *wq = qhp ? &qhp->wq : NULL;
...
ret = poll_cq(wq, ...);
if (ret)
goto out;
poll_cq(wq, ...) always returns a non-zero status if 'wq' is NULL,
either on a t4_next_cqe() error or on a 'wq == NULL' check.
Therefore, checking 'qhp' again after poll_cq() is redundant.
BTW, there're also 'qhp' dereference cases below poll_cq() without
any checks (c4iw_invalidate_mr(qhp->rhp,...)).
Detected using the static analysis tool - Svace.
Fixes: 4ab39e2f98f2 ("RDMA/cxgb4: Make c4iw_poll_cq_one() easier to analyze")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
drivers/infiniband/hw/cxgb4/cq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/cxgb4/cq.c b/drivers/infiniband/hw/cxgb4/cq.c
index c7e8d7b3baa1..7e2835dcbc1c 100644
--- a/drivers/infiniband/hw/cxgb4/cq.c
+++ b/drivers/infiniband/hw/cxgb4/cq.c
@@ -767,7 +767,7 @@ static int __c4iw_poll_cq_one(struct c4iw_cq *chp, struct c4iw_qp *qhp,
goto out;
wc->wr_id = cookie;
- wc->qp = qhp ? &qhp->ibqp : NULL;
+ wc->qp = &qhp->ibqp;
wc->vendor_err = CQE_STATUS(&cqe);
wc->wc_flags = 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one()
2022-12-15 12:30 [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one() Alexey Kodanev
@ 2022-12-18 10:00 ` Leon Romanovsky
2022-12-27 13:49 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-12-18 10:00 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: linux-rdma
On Thu, Dec 15, 2022 at 03:30:30PM +0300, Alexey Kodanev wrote:
> If 'qhp' is NULL then 'wq' is also NULL:
>
> struct t4_wq *wq = qhp ? &qhp->wq : NULL;
> ...
> ret = poll_cq(wq, ...);
> if (ret)
> goto out;
>
> poll_cq(wq, ...) always returns a non-zero status if 'wq' is NULL,
> either on a t4_next_cqe() error or on a 'wq == NULL' check.
>
> Therefore, checking 'qhp' again after poll_cq() is redundant.
>
> BTW, there're also 'qhp' dereference cases below poll_cq() without
> any checks (c4iw_invalidate_mr(qhp->rhp,...)).
>
> Detected using the static analysis tool - Svace.
> Fixes: 4ab39e2f98f2 ("RDMA/cxgb4: Make c4iw_poll_cq_one() easier to analyze")
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> ---
> drivers/infiniband/hw/cxgb4/cq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Let's wait till merge window ends.
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one()
2022-12-15 12:30 [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one() Alexey Kodanev
2022-12-18 10:00 ` Leon Romanovsky
@ 2022-12-27 13:49 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-12-27 13:49 UTC (permalink / raw)
To: Alexey Kodanev, linux-rdma
On Thu, 15 Dec 2022 15:30:30 +0300, Alexey Kodanev wrote:
> If 'qhp' is NULL then 'wq' is also NULL:
>
> struct t4_wq *wq = qhp ? &qhp->wq : NULL;
> ...
> ret = poll_cq(wq, ...);
> if (ret)
> goto out;
>
> [...]
Applied, thanks!
[1/1] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one()
https://git.kernel.org/rdma/rdma/c/cab30a98352511
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-27 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 12:30 [PATCH rdma-next] RDMA/cxgb4: remove unnecessary NULL check in __c4iw_poll_cq_one() Alexey Kodanev
2022-12-18 10:00 ` Leon Romanovsky
2022-12-27 13:49 ` Leon Romanovsky
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).