Skip to content

Commit

Permalink
net/mlx5: Fix incorrect raw command length parsing
Browse files Browse the repository at this point in the history
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: e126ba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Signed-off-by: Alex Vesker <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>
  • Loading branch information
alexvesker authored and Saeed Mahameed committed Jun 26, 2018
1 parent d14fcb8 commit 603b7bc
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/ethernet/mellanox/mlx5/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 603b7bc

Please sign in to comment.