From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> commit a75badebfdc0b3823054bedf112edb54d6357c75 upstream. The atomic_inc() needs to be paired with an atomic_dec() on the error path. Fixes: 514aee660df4 ("RDMA: Globally allocate and release QP memory") Link: https://lore.kernel.org/r/20220118091104.GA11671@kili Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Reviewed-by: Leon Romanovsky <leonro@xxxxxxxxxx> Reviewed-by: Bernard Metzler <bmt@xxxxxxxxxxxxxx> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/infiniband/sw/siw/siw_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/sw/siw/siw_verbs.c +++ b/drivers/infiniband/sw/siw/siw_verbs.c @@ -311,7 +311,8 @@ int siw_create_qp(struct ib_qp *ibqp, st 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"); Patches currently in stable-queue which might be from dan.carpenter@xxxxxxxxxx are queue-5.15/ib-cm-release-previously-acquired-reference-counter-in-the-cm_id_priv.patch queue-5.15/asoc-max9759-fix-underflow-in-speaker_gain_control_put.patch queue-5.15/net-stmmac-dwmac-visconti-no-change-to-ether_clock_sel-for-unexpected-speed-request.patch queue-5.15/rdma-siw-fix-refcounting-leak-in-siw_create_qp.patch queue-5.15/drm-i915-overlay-prevent-divide-by-zero-bugs-in-scaling.patch