Commit 7f60951f authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Jason Gunthorpe

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: a926a903 ("RDMA/rxe: Do not call dev_mc_add/del() under a spinlock")
Link: https://lore.kernel.org/r/fe137cd8b1f17593243aa73d59c18ea71ab9ee36.1653225896.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent a6f844da
...@@ -206,8 +206,10 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid) ...@@ -206,8 +206,10 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid)
/* speculative alloc of new mcg */ /* speculative alloc of new mcg */
mcg = kzalloc(sizeof(*mcg), GFP_KERNEL); mcg = kzalloc(sizeof(*mcg), GFP_KERNEL);
if (!mcg) if (!mcg) {
return ERR_PTR(-ENOMEM); err = -ENOMEM;
goto err_dec;
}
spin_lock_bh(&rxe->mcg_lock); spin_lock_bh(&rxe->mcg_lock);
/* re-check to see if someone else just added it */ /* re-check to see if someone else just added it */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment