Skip to content

Commit

Permalink
net/mlx4_core: Replace sscanf() with kstrtoint()
Browse files Browse the repository at this point in the history
It is not safe to use sscanf.

Signed-off-by: Dotan Barak <dotanb@dev.mellanox.com>
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dotan Barak authored and David S. Miller committed Jun 25, 2013
1 parent 42f1e90 commit 618fad9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/mellanox/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,11 @@ static ssize_t set_port_ib_mtu(struct device *dev,
return -EINVAL;
}

err = sscanf(buf, "%d", &mtu);
if (err > 0)
err = kstrtoint(buf, 0, &mtu);
if (!err)
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);
return -EINVAL;
}
Expand Down

0 comments on commit 618fad9

Please sign in to comment.