]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ethtool: Null-terminate filename passed to ethtool_ops::flash_device
authorBen Hutchings <bhutchings@solarflare.com>
Wed, 1 Feb 2012 09:32:25 +0000 (09:32 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 30 May 2012 23:44:03 +0000 (00:44 +0100)
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 <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/net/ethernet/emulex/benet/be_ethtool.c
net/core/ethtool.c

index bf8153ea4ed81a6a443681c551e7f45fd9aa7bc8..7570c1a95e2b7d0fecadb04fc8daca6bbacd3f23 100644 (file)
@@ -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
index f444817071245006200ba882a2f085ee43ae3773..2b587ec0714010aea57c25d7697cd520647694bd 100644 (file)
@@ -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);
 }