Skip to content

Commit 7f60951

Browse files
tititiou36jgunthorpe
authored andcommitted
RDMA/rxe: Fix an error handling path in rxe_get_mcg()
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 <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent a6f844d commit 7f60951

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/infiniband/sw/rxe/rxe_mcast.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid)
206206

207207
/* speculative alloc of new mcg */
208208
mcg = kzalloc(sizeof(*mcg), GFP_KERNEL);
209-
if (!mcg)
210-
return ERR_PTR(-ENOMEM);
209+
if (!mcg) {
210+
err = -ENOMEM;
211+
goto err_dec;
212+
}
211213

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

0 commit comments

Comments
 (0)