net/mlx5: Fix incorrect raw command length parsing
[ Upstream commit603b7bcff8
] 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:e126ba97db
("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: Alex Vesker <valex@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e555ae018b
commit
5b3cc7f9b3
@ -1256,7 +1256,7 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
|
|||||||
{
|
{
|
||||||
struct mlx5_core_dev *dev = filp->private_data;
|
struct mlx5_core_dev *dev = filp->private_data;
|
||||||
struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
|
struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
|
||||||
char outlen_str[8];
|
char outlen_str[8] = {0};
|
||||||
int outlen;
|
int outlen;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int err;
|
int err;
|
||||||
@ -1271,8 +1271,6 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
|
|||||||
if (copy_from_user(outlen_str, buf, count))
|
if (copy_from_user(outlen_str, buf, count))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
outlen_str[7] = 0;
|
|
||||||
|
|
||||||
err = sscanf(outlen_str, "%d", &outlen);
|
err = sscanf(outlen_str, "%d", &outlen);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
Reference in New Issue
Block a user