diff options
| author | Ben Hutchings <bhutchings@solarflare.com> | 2012-02-01 04:32:25 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-02-01 14:47:17 -0500 |
| commit | 786f528119722f564a22ad953411374e06116333 (patch) | |
| tree | 122ca6128b967fc4e91ff9a974181536a55f64ed | |
| parent | efcdbf24fd5daa88060869e51ed49f68b7ac8708 (diff) | |
ethtool: Null-terminate filename passed to ethtool_ops::flash_device
The parameters for ETHTOOL_FLASHDEV include a filename, which ought to
be null-terminated. Currently the only driver that implements
ethtool_ops::flash_device attempts to add a null terminator if
necessary, but does it wrongly. Do it in the ethtool core instead.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/emulex/benet/be_ethtool.c | 6 | ||||
| -rw-r--r-- | net/core/ethtool.c | 2 |
2 files changed, 3 insertions, 5 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index 6db6b6ae5e9b..802e5ddef8a8 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c | |||
| @@ -716,12 +716,8 @@ static int | |||
| 716 | be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) | 716 | be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) |
| 717 | { | 717 | { |
| 718 | struct be_adapter *adapter = netdev_priv(netdev); | 718 | struct be_adapter *adapter = netdev_priv(netdev); |
| 719 | char file_name[ETHTOOL_FLASH_MAX_FILENAME]; | ||
| 720 | 719 | ||
| 721 | file_name[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0; | 720 | return be_load_fw(adapter, efl->data); |
| 722 | strcpy(file_name, efl->data); | ||
| 723 | |||
| 724 | return be_load_fw(adapter, file_name); | ||
| 725 | } | 721 | } |
| 726 | 722 | ||
| 727 | static int | 723 | static int |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 369b41894527..3f79db1b612a 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -1190,6 +1190,8 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev, | |||
| 1190 | if (!dev->ethtool_ops->flash_device) | 1190 | if (!dev->ethtool_ops->flash_device) |
| 1191 | return -EOPNOTSUPP; | 1191 | return -EOPNOTSUPP; |
| 1192 | 1192 | ||
| 1193 | efl.data[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0; | ||
| 1194 | |||
| 1193 | return dev->ethtool_ops->flash_device(dev, &efl); | 1195 | return dev->ethtool_ops->flash_device(dev, &efl); |
| 1194 | } | 1196 | } |
| 1195 | 1197 | ||
