* [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp()
@ 2022-01-18 9:11 Dan Carpenter
2022-01-18 9:56 ` Leon Romanovsky
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-01-18 9:11 UTC (permalink / raw)
To: Bernard Metzler, Leon Romanovsky
Cc: Jason Gunthorpe, Gal Pressman, Dennis Dalessandro, linux-rdma,
kernel-janitors
The atomic_inc() needs to be paired with an atomic_dec() on the error
path.
Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/infiniband/sw/siw/siw_verbs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c
index a3dd2cb6d5c9..54ef367b074a 100644
--- a/drivers/infiniband/sw/siw/siw_verbs.c
+++ b/drivers/infiniband/sw/siw/siw_verbs.c
@@ -313,7 +313,8 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
if (atomic_inc_return(&sdev->num_qp) > SIW_MAX_QP) {
siw_dbg(base_dev, "too many QP's\n");
- return -ENOMEM;
+ rv = -ENOMEM;
+ goto err_atomic;
}
if (attrs->qp_type != IB_QPT_RC) {
siw_dbg(base_dev, "only RC QP's supported\n");
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp()
2022-01-18 9:11 [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp() Dan Carpenter
@ 2022-01-18 9:56 ` Leon Romanovsky
2022-01-18 11:38 ` Bernard Metzler
2022-01-28 16:40 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2022-01-18 9:56 UTC (permalink / raw)
To: Dan Carpenter
Cc: Bernard Metzler, Jason Gunthorpe, Gal Pressman,
Dennis Dalessandro, linux-rdma, kernel-janitors
On Tue, Jan 18, 2022 at 12:11:04PM +0300, Dan Carpenter wrote:
> The atomic_inc() needs to be paired with an atomic_dec() on the error
> path.
>
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/infiniband/sw/siw/siw_verbs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp()
2022-01-18 9:11 [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp() Dan Carpenter
2022-01-18 9:56 ` Leon Romanovsky
@ 2022-01-18 11:38 ` Bernard Metzler
2022-01-28 16:40 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Bernard Metzler @ 2022-01-18 11:38 UTC (permalink / raw)
To: Dan Carpenter, Leon Romanovsky
Cc: Jason Gunthorpe, Gal Pressman, Dennis Dalessandro,
linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@oracle.com>
> Sent: Tuesday, 18 January 2022 10:11
> To: Bernard Metzler <BMT@zurich.ibm.com>; Leon Romanovsky
> <leonro@nvidia.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>; Gal Pressman <galpress@amazon.com>;
> Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>; linux-
> rdma@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: [EXTERNAL] [PATCH] RDMA/siw: fix refcounting leak in
> siw_create_qp()
>
> The atomic_inc() needs to be paired with an atomic_dec() on the error
> path.
>
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/infiniband/sw/siw/siw_verbs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/sw/siw/siw_verbs.c
> b/drivers/infiniband/sw/siw/siw_verbs.c
> index a3dd2cb6d5c9..54ef367b074a 100644
> --- a/drivers/infiniband/sw/siw/siw_verbs.c
> +++ b/drivers/infiniband/sw/siw/siw_verbs.c
> @@ -313,7 +313,8 @@ int siw_create_qp(struct ib_qp *ibqp, struct
> ib_qp_init_attr *attrs,
>
> if (atomic_inc_return(&sdev->num_qp) > SIW_MAX_QP) {
> siw_dbg(base_dev, "too many QP's\n");
> - return -ENOMEM;
> + rv = -ENOMEM;
> + goto err_atomic;
> }
> if (attrs->qp_type != IB_QPT_RC) {
> siw_dbg(base_dev, "only RC QP's supported\n");
> --
> 2.20.1
Good catch, thank you!
Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp()
2022-01-18 9:11 [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp() Dan Carpenter
2022-01-18 9:56 ` Leon Romanovsky
2022-01-18 11:38 ` Bernard Metzler
@ 2022-01-28 16:40 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2022-01-28 16:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: Bernard Metzler, Leon Romanovsky, Gal Pressman,
Dennis Dalessandro, linux-rdma, kernel-janitors
On Tue, Jan 18, 2022 at 12:11:04PM +0300, Dan Carpenter wrote:
> The atomic_inc() needs to be paired with an atomic_dec() on the error
> path.
>
> Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
> ---
> drivers/infiniband/sw/siw/siw_verbs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-28 16:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 9:11 [PATCH] RDMA/siw: fix refcounting leak in siw_create_qp() Dan Carpenter
2022-01-18 9:56 ` Leon Romanovsky
2022-01-18 11:38 ` Bernard Metzler
2022-01-28 16:40 ` Jason Gunthorpe
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).