diff mbox series

[rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure

Message ID 12a0e83f18cfad4b5f62654f141e240d04915e10.1643622264.git.leonro@nvidia.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [rdma-rc] RDMA/mlx4: Don't continue event handler after memory allocation failure | expand

Commit Message

Leon Romanovsky Jan. 31, 2022, 9:45 a.m. UTC
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(-)

Comments

Haakon Bugge Jan. 31, 2022, 10:14 a.m. UTC | #1
> 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
>
Jason Gunthorpe Feb. 1, 2022, 2:19 p.m. UTC | #2
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
diff mbox series

Patch

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);