linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ocrdma: Fix potential null-ptr-deref in ocrdma_is_qp_in_rq_flushlist()
@ 2023-02-15 10:10 Natalia Petrova
  2023-02-15 12:28 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Natalia Petrova @ 2023-02-15 10:10 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Natalia Petrova, Leon Romanovsky, linux-rdma, linux-kernel, lvc-project

The 'qp->rq_cq' pointer can be equal to null in ocrdma_destroy_qp()
function. That's why 'qp->rq_cq' should be checked for null in
ocrdma_del_flush_qp() before it will be dereferenced in
ocrdma_is_qp_in_rq_flushlist().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: fe2caefcdf58 ("RDMA/ocrdma: Add driver for Emulex OneConnect IBoE RDMA adapter")
Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index dd4021b11963..a3d994ee178c 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1660,7 +1660,7 @@ void ocrdma_del_flush_qp(struct ocrdma_qp *qp)
 	found = ocrdma_is_qp_in_sq_flushlist(qp->sq_cq, qp);
 	if (found)
 		list_del(&qp->sq_entry);
-	if (!qp->srq) {
+	if (!qp->srq && qp->rq_cq) {
 		found = ocrdma_is_qp_in_rq_flushlist(qp->rq_cq, qp);
 		if (found)
 			list_del(&qp->rq_entry);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ocrdma: Fix potential null-ptr-deref in ocrdma_is_qp_in_rq_flushlist()
  2023-02-15 10:10 [PATCH] ocrdma: Fix potential null-ptr-deref in ocrdma_is_qp_in_rq_flushlist() Natalia Petrova
@ 2023-02-15 12:28 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2023-02-15 12:28 UTC (permalink / raw)
  To: Natalia Petrova; +Cc: Jason Gunthorpe, linux-rdma, linux-kernel, lvc-project

On Wed, Feb 15, 2023 at 01:10:45PM +0300, Natalia Petrova wrote:
> The 'qp->rq_cq' pointer can be equal to null in ocrdma_destroy_qp()

How is it possible that we will have valid QP without rq_cq?

Thanks

> function. That's why 'qp->rq_cq' should be checked for null in
> ocrdma_del_flush_qp() before it will be dereferenced in
> ocrdma_is_qp_in_rq_flushlist().
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: fe2caefcdf58 ("RDMA/ocrdma: Add driver for Emulex OneConnect IBoE RDMA adapter")
> Signed-off-by: Natalia Petrova <n.petrova@fintech.ru>
> ---
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index dd4021b11963..a3d994ee178c 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -1660,7 +1660,7 @@ void ocrdma_del_flush_qp(struct ocrdma_qp *qp)
>  	found = ocrdma_is_qp_in_sq_flushlist(qp->sq_cq, qp);
>  	if (found)
>  		list_del(&qp->sq_entry);
> -	if (!qp->srq) {
> +	if (!qp->srq && qp->rq_cq) {
>  		found = ocrdma_is_qp_in_rq_flushlist(qp->rq_cq, qp);
>  		if (found)
>  			list_del(&qp->rq_entry);
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-15 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 10:10 [PATCH] ocrdma: Fix potential null-ptr-deref in ocrdma_is_qp_in_rq_flushlist() Natalia Petrova
2023-02-15 12:28 ` 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).