linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure
@ 2022-01-31  9:45 Leon Romanovsky
  2022-01-31 10:14 ` Haakon Bugge
  2022-02-01 14:19 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-01-31  9:45 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Leon Romanovsky, Jack Morgenstein, linux-rdma, Yishai Hadas

From: Leon Romanovsky <leonro@nvidia.com>

The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
event handler will cause skip the assignment logic, but ib_dispatch_event()
will be called anyway.

Fix it by calling to return instead of break after memory allocation
failure.

Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp_snoop")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx4/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 1c3d97229988..93b1650eacfa 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -3237,7 +3237,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
 		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
 		if (!ew)
-			break;
+			return;
 
 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
 		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure
  2022-01-31  9:45 [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure Leon Romanovsky
@ 2022-01-31 10:14 ` Haakon Bugge
  2022-02-01 14:19 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Haakon Bugge @ 2022-01-31 10:14 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Jason Gunthorpe, Leon Romanovsky, Jack Morgenstein,
	OFED mailing list, Yishai Hadas



> On 31 Jan 2022, at 10:45, Leon Romanovsky <leon@kernel.org> wrote:
> 
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
> event handler will cause skip the assignment logic, but ib_dispatch_event()
> will be called anyway.
> 
> Fix it by calling to return instead of break after memory allocation
> failure.
> 
> Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp_snoop")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

LGTM,

Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>


Thxs, Håkon

> ---
> drivers/infiniband/hw/mlx4/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 1c3d97229988..93b1650eacfa 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -3237,7 +3237,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
> 	case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
> 		ew = kmalloc(sizeof *ew, GFP_ATOMIC);
> 		if (!ew)
> -			break;
> +			return;
> 
> 		INIT_WORK(&ew->work, handle_port_mgmt_change_event);
> 		memcpy(&ew->ib_eqe, eqe, sizeof *eqe);
> -- 
> 2.34.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure
  2022-01-31  9:45 [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure Leon Romanovsky
  2022-01-31 10:14 ` Haakon Bugge
@ 2022-02-01 14:19 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2022-02-01 14:19 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Leon Romanovsky, Jack Morgenstein, linux-rdma, Yishai Hadas

On Mon, Jan 31, 2022 at 11:45:26AM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
> event handler will cause skip the assignment logic, but ib_dispatch_event()
> will be called anyway.
> 
> Fix it by calling to return instead of break after memory allocation
> failure.
> 
> Fixes: 00f5ce99dc6e ("mlx4: Use port management change event instead of smp_snoop")
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-01 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-31  9:45 [PATCH rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure Leon Romanovsky
2022-01-31 10:14 ` Haakon Bugge
2022-02-01 14:19 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).