* [PATCH] RDMA/rxe: Fix an error handling path in rxe_get_mcg()
@ 2022-05-22 13:25 Christophe JAILLET
2022-05-24 15:56 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-05-22 13:25 UTC (permalink / raw)
To: dan.carpenter, Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, Bob Pearson
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma
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: a926a903b7dc ("RDMA/rxe: Do not call dev_mc_add/del() under a spinlock")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/infiniband/sw/rxe/rxe_mcast.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_mcast.c b/drivers/infiniband/sw/rxe/rxe_mcast.c
index 873a9b10307c..86cc2e18a7fd 100644
--- a/drivers/infiniband/sw/rxe/rxe_mcast.c
+++ b/drivers/infiniband/sw/rxe/rxe_mcast.c
@@ -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 */
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] RDMA/rxe: Fix an error handling path in rxe_get_mcg()
2022-05-22 13:25 [PATCH] RDMA/rxe: Fix an error handling path in rxe_get_mcg() Christophe JAILLET
@ 2022-05-24 15:56 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2022-05-24 15:56 UTC (permalink / raw)
To: Christophe JAILLET
Cc: dan.carpenter, Zhu Yanjun, Leon Romanovsky, Bob Pearson,
linux-kernel, kernel-janitors, linux-rdma
On Sun, May 22, 2022 at 03:25:08PM +0200, Christophe JAILLET wrote:
> 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: a926a903b7dc ("RDMA/rxe: Do not call dev_mc_add/del() under a spinlock")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/infiniband/sw/rxe/rxe_mcast.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-24 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22 13:25 [PATCH] RDMA/rxe: Fix an error handling path in rxe_get_mcg() Christophe JAILLET
2022-05-24 15:56 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.