All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning
@ 2019-12-26  8:41 Leon Romanovsky
  2019-12-26  9:16 ` Ido Schimmel
  2019-12-26 19:50 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Romanovsky @ 2019-12-26  8:41 UTC (permalink / raw)
  To: David S . Miller, mlxsw
  Cc: Vladyslav Tarasiuk, linux-netdev, Aya Levin, Leon Romanovsky

From: Vladyslav Tarasiuk <vladyslavt@mellanox.com>

The burning process requires to perform internal allocations of large
chunks of memory. This memory doesn't need to be contiguous and can be
safely allocated by vzalloc() instead of kzalloc(). This patch changes
such allocation to avoid possible out-of-memory failure.

Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: Aya Levin <ayal@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
index 544344ac4894..79057af4fe99 100644
--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
+++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
@@ -6,6 +6,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/netlink.h>
+#include <linux/vmalloc.h>
 #include <linux/xz.h>
 #include "mlxfw_mfa2.h"
 #include "mlxfw_mfa2_file.h"
@@ -548,7 +549,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
 	comp_size = be32_to_cpu(comp->size);
 	comp_buf_size = comp_size + mlxfw_mfa2_comp_magic_len;

-	comp_data = kmalloc(sizeof(*comp_data) + comp_buf_size, GFP_KERNEL);
+	comp_data = vzalloc(sizeof(*comp_data) + comp_buf_size);
 	if (!comp_data)
 		return ERR_PTR(-ENOMEM);
 	comp_data->comp.data_size = comp_size;
@@ -570,7 +571,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
 	comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len;
 	return &comp_data->comp;
 err_out:
-	kfree(comp_data);
+	vfree(comp_data);
 	return ERR_PTR(err);
 }

@@ -579,7 +580,7 @@ void mlxfw_mfa2_file_component_put(struct mlxfw_mfa2_component *comp)
 	const struct mlxfw_mfa2_comp_data *comp_data;

 	comp_data = container_of(comp, struct mlxfw_mfa2_comp_data, comp);
-	kfree(comp_data);
+	vfree(comp_data);
 }

 void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file)
--
2.20.1


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

* Re: [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning
  2019-12-26  8:41 [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning Leon Romanovsky
@ 2019-12-26  9:16 ` Ido Schimmel
  2019-12-26 19:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2019-12-26  9:16 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: David S . Miller, mlxsw, Vladyslav Tarasiuk, linux-netdev,
	Aya Levin, Leon Romanovsky

On Thu, Dec 26, 2019 at 10:41:56AM +0200, Leon Romanovsky wrote:
> From: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
> 
> The burning process requires to perform internal allocations of large
> chunks of memory. This memory doesn't need to be contiguous and can be
> safely allocated by vzalloc() instead of kzalloc(). This patch changes
> such allocation to avoid possible out-of-memory failure.
> 
> Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
> Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
> Reviewed-by: Aya Levin <ayal@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>

Tested-by: Ido Schimmel <idosch@mellanox.com>

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

* Re: [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning
  2019-12-26  8:41 [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning Leon Romanovsky
  2019-12-26  9:16 ` Ido Schimmel
@ 2019-12-26 19:50 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-12-26 19:50 UTC (permalink / raw)
  To: leon; +Cc: mlxsw, vladyslavt, netdev, ayal, leonro

From: Leon Romanovsky <leon@kernel.org>
Date: Thu, 26 Dec 2019 10:41:56 +0200

> From: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
> 
> The burning process requires to perform internal allocations of large
> chunks of memory. This memory doesn't need to be contiguous and can be
> safely allocated by vzalloc() instead of kzalloc(). This patch changes
> such allocation to avoid possible out-of-memory failure.
> 
> Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
> Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
> Reviewed-by: Aya Levin <ayal@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>

Applied and queued up for -stable, thank you.

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

end of thread, other threads:[~2019-12-26 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26  8:41 [PATCH net] net/mlxfw: Fix out-of-memory error in mfa2 flash burning Leon Romanovsky
2019-12-26  9:16 ` Ido Schimmel
2019-12-26 19:50 ` David Miller

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.