Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Link: https://lore.kernel.org/r/20220118091104.GA11671@kili
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Dan Carpenter and committed by
Jason Gunthorpe
a75badeb 36e8169e

+2 -1
+2 -1
drivers/infiniband/sw/siw/siw_verbs.c
··· 313 313 314 314 if (atomic_inc_return(&sdev->num_qp) > SIW_MAX_QP) { 315 315 siw_dbg(base_dev, "too many QP's\n"); 316 - return -ENOMEM; 316 + rv = -ENOMEM; 317 + goto err_atomic; 317 318 } 318 319 if (attrs->qp_type != IB_QPT_RC) { 319 320 siw_dbg(base_dev, "only RC QP's supported\n");