Skip to content

Commit

Permalink
RDMA/rxe: Fix an error handling path in rxe_get_mcg()
Browse files Browse the repository at this point in the history
The commit in the Fixes tag has shuffled some code.
Now 'mcg_num' is incremented before the kzalloc(). So if the memory
allocation fails, this increment must be undone.

Fixes: a926a90 ("RDMA/rxe: Do not call dev_mc_add/del() under a spinlock")
Link: https://lore.kernel.org/r/fe137cd8b1f17593243aa73d59c18ea71ab9ee36.1653225896.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
  • Loading branch information
Christophe JAILLET authored and Jason Gunthorpe committed May 24, 2022
1 parent a6f844d commit 7f60951
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/infiniband/sw/rxe/rxe_mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid)

/* speculative alloc of new mcg */
mcg = kzalloc(sizeof(*mcg), GFP_KERNEL);
if (!mcg)
return ERR_PTR(-ENOMEM);
if (!mcg) {
err = -ENOMEM;
goto err_dec;
}

spin_lock_bh(&rxe->mcg_lock);
/* re-check to see if someone else just added it */
Expand Down

0 comments on commit 7f60951

Please sign in to comment.