RDMA/siw: fix refcounting leak in siw_create_qp()
Subsystems (3)
PATCH 1/1 RDMA/siw: fix refcounting leak in siw_create_qp()
The atomic_inc() needs to be paired with an atomic_dec() on the error path.
--- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_verbs.c +2 -1
@@ -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" );
Signature · 1 line
2.20.1
Quoted 9 lines · Dan Carpenter
The
atomic_inc()needs to be paired with anatomic_dec()on the error path.Fixes 514aee660df4 ("RDMA: Globally allocate and release QP memory")Signed-off-by Dan Carpenter <[email protected]>--- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Thanks,
Quoted 35 lines
-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Tuesday, 18 January 2022 10:11
To: Bernard Metzler <[email protected]>; Leon Romanovsky <[email protected]>
Cc: Jason Gunthorpe <[email protected]>; Gal Pressman <[email protected]>; Dennis Dalessandro <[email protected]>; linux- [email protected]; [email protected]
Subject: [EXTERNAL] [PATCH] RDMA/siw: fix refcounting leak insiw_create_qp()The
atomic_inc()needs to be paired with anatomic_dec()on the error path.Fixes 514aee660df4 ("RDMA: Globally allocate and release QP memory")Signed-off-by Dan Carpenter <[email protected]>--- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/sw/siw/siw_verbs.c +2
-1@@ -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 ) {
Quoted 3 lines
siw_dbg(base_dev, "only RC QP's supported\n");
--
2.20.1
Good catch, thank you!
Quoted 10 lines · Dan Carpenter
The
atomic_inc()needs to be paired with anatomic_dec()on the error path.Fixes 514aee660df4 ("RDMA: Globally allocate and release QP memory")Signed-off-by Dan Carpenter <[email protected]>Reviewed-by Leon Romanovsky <[email protected]>Reviewed-by Bernard Metzler <[email protected]>--- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to for-rc, thanks
Jason