Commit 6538eea7 authored by Vladyslav Tarasiuk's avatar Vladyslav Tarasiuk Committed by Greg Kroah-Hartman

net/mlxfw: Fix out-of-memory error in mfa2 flash burning

[ Upstream commit a5bcd72e ]

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: 410ed13c ("Add the mlxfw module for Mellanox firmware flash process")
Signed-off-by: default avatarVladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: default avatarAya Levin <ayal@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Tested-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3990d690
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/vmalloc.h>
#include <linux/xz.h> #include <linux/xz.h>
#include "mlxfw_mfa2.h" #include "mlxfw_mfa2.h"
#include "mlxfw_mfa2_file.h" #include "mlxfw_mfa2_file.h"
...@@ -579,7 +580,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file, ...@@ -579,7 +580,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
comp_size = be32_to_cpu(comp->size); comp_size = be32_to_cpu(comp->size);
comp_buf_size = comp_size + mlxfw_mfa2_comp_magic_len; 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) if (!comp_data)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
comp_data->comp.data_size = comp_size; comp_data->comp.data_size = comp_size;
...@@ -601,7 +602,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file, ...@@ -601,7 +602,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; comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len;
return &comp_data->comp; return &comp_data->comp;
err_out: err_out:
kfree(comp_data); vfree(comp_data);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -610,7 +611,7 @@ void mlxfw_mfa2_file_component_put(struct mlxfw_mfa2_component *comp) ...@@ -610,7 +611,7 @@ void mlxfw_mfa2_file_component_put(struct mlxfw_mfa2_component *comp)
const struct mlxfw_mfa2_comp_data *comp_data; const struct mlxfw_mfa2_comp_data *comp_data;
comp_data = container_of(comp, struct mlxfw_mfa2_comp_data, comp); 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) void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment