From: Ben Hutchings Date: Wed, 1 Feb 2012 09:32:25 +0000 (+0000) Subject: ethtool: Null-terminate filename passed to ethtool_ops::flash_device X-Git-Tag: v3.2.19~15 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=077ae2b73b4c110e9d458b071a61c9f2b33ee58e ethtool: Null-terminate filename passed to ethtool_ops::flash_device commit 786f528119722f564a22ad953411374e06116333 upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c index bf8153ea4ed8..7570c1a95e2b 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -649,12 +649,8 @@ static int be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) { struct be_adapter *adapter = netdev_priv(netdev); - char file_name[ETHTOOL_FLASH_MAX_FILENAME]; - file_name[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0; - strcpy(file_name, efl->data); - - return be_load_fw(adapter, file_name); + return be_load_fw(adapter, efl->data); } static int diff --git a/net/core/ethtool.c b/net/core/ethtool.c index f44481707124..2b587ec07140 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -1549,6 +1549,8 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev, if (!dev->ethtool_ops->flash_device) return -EOPNOTSUPP; + efl.data[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0; + return dev->ethtool_ops->flash_device(dev, &efl); }