Commit 618fad95 authored by Dotan Barak's avatar Dotan Barak Committed by David S. Miller

net/mlx4_core: Replace sscanf() with kstrtoint()

It is not safe to use sscanf.
Signed-off-by: default avatarDotan Barak <dotanb@dev.mellanox.com>
Signed-off-by: default avatarVladimir Sokolovsky <vlad@mellanox.com>
Signed-off-by: default avatarAmir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42f1e902
...@@ -839,11 +839,11 @@ static ssize_t set_port_ib_mtu(struct device *dev, ...@@ -839,11 +839,11 @@ static ssize_t set_port_ib_mtu(struct device *dev,
return -EINVAL; return -EINVAL;
} }
err = sscanf(buf, "%d", &mtu); err = kstrtoint(buf, 0, &mtu);
if (err > 0) if (!err)
ibta_mtu = int_to_ibta_mtu(mtu); ibta_mtu = int_to_ibta_mtu(mtu);
if (err <= 0 || ibta_mtu < 0) { if (err || ibta_mtu < 0) {
mlx4_err(mdev, "%s is invalid IBTA mtu\n", buf); mlx4_err(mdev, "%s is invalid IBTA mtu\n", buf);
return -EINVAL; return -EINVAL;
} }
......
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