netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ethtool: Null-terminate filename passed to ethtool_ops::flash_device
@ 2012-02-01 19:32 Ben Hutchings
  2012-02-01 19:47 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Hutchings @ 2012-02-01 19:32 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Sathya Perla, Subbu Seetharaman, Ajit Khaparde

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>
---
Compile-tested only.

Ben.

 drivers/net/ethernet/emulex/benet/be_ethtool.c |    6 +-----
 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 6db6b6a..802e5dd 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
 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 369b418..3f79db1 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,
 	if (!dev->ethtool_ops->flash_device)
 		return -EOPNOTSUPP;
 
+	efl.data[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0;
+
 	return dev->ethtool_ops->flash_device(dev, &efl);
 }
 
-- 
1.7.7.5


-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] ethtool: Null-terminate filename passed to ethtool_ops::flash_device
  2012-02-01 19:32 [PATCH net] ethtool: Null-terminate filename passed to ethtool_ops::flash_device Ben Hutchings
@ 2012-02-01 19:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-02-01 19:47 UTC (permalink / raw)
  To: bhutchings; +Cc: netdev, sathya.perla, subbu.seetharaman, ajit.khaparde

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Wed, 1 Feb 2012 19:32:25 +0000

> 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>

Applied, thanks Ben.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-01 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01 19:32 [PATCH net] ethtool: Null-terminate filename passed to ethtool_ops::flash_device Ben Hutchings
2012-02-01 19:47 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).