mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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: a926a903b7
("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>
This commit is contained in:
parent
a6f844da39
commit
7f60951ff4
1 changed files with 4 additions and 2 deletions
|
@ -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 */
|
||||||
|
|
Loading…
Add table
Reference in a new issue