summaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorAlex Vesker2018-05-25 19:25:59 +0200
committerSaeed Mahameed2018-06-27 00:26:34 +0200
commit603b7bcff824740500ddfa001d7a7168b0b38542 (patch)
tree58cc8e39cf706ae2a12da898837cb2441890f0f5 /drivers/net
parentnet/mlx5: Fix wrong size allocation for QoS ETC TC regitster (diff)
downloadkernel-qcow2-linux-603b7bcff824740500ddfa001d7a7168b0b38542.tar.gz
kernel-qcow2-linux-603b7bcff824740500ddfa001d7a7168b0b38542.tar.xz
kernel-qcow2-linux-603b7bcff824740500ddfa001d7a7168b0b38542.zip
net/mlx5: Fix incorrect raw command length parsing
The NULL character was not set correctly for the string containing the command length, this caused failures reading the output of the command due to a random length. The fix is to initialize the output length string. Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: Alex Vesker <valex@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 487388aed98f..2db5fe571594 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -1276,7 +1276,7 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
{
struct mlx5_core_dev *dev = filp->private_data;
struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
- char outlen_str[8];
+ char outlen_str[8] = {0};
int outlen;
void *ptr;
int err;
@@ -1291,8 +1291,6 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
if (copy_from_user(outlen_str, buf, count))
return -EFAULT;
- outlen_str[7] = 0;
-
err = sscanf(outlen_str, "%d", &outlen);
if (err < 0)
return err;