diff mbox

[1/2] ethtool: Clear the command data structure before sending requests

Message ID 1432334609-3971-2-git-send-email-aparames@broadcom.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Arun Parameswaran May 22, 2015, 10:43 p.m. UTC
The 'ethtool' is not clearing the command data structure in the
do_gset() & do_sset() API's while sending commands to get/set
parametres. This used to work since the Kernel clears the
data structure (which was a bug and is being fixed).

This patch adds a 'memset' to the do_gset() & do_sset() to clear
the command data structure. This will prevent the 'ethtool' from
passing wrong parametres, for example incorrect 'phyad'.

Signed-off-by: Arun Parameswaran <aparames@broadcom.com>
Reviewed-by: JD (Jiandong) Zheng <jdzheng@broadcom.com>
---
 ethtool.c |    3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/ethtool.c b/ethtool.c
index 01b13a6..668c189 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2275,6 +2275,7 @@  static int do_gset(struct cmd_context *ctx)
 
 	fprintf(stdout, "Settings for %s:\n", ctx->devname);
 
+	memset(&ecmd, 0, sizeof(struct ethtool_cmd));
 	ecmd.cmd = ETHTOOL_GSET;
 	err = send_ioctl(ctx, &ecmd);
 	if (err == 0) {
@@ -2520,6 +2521,8 @@  static int do_sset(struct cmd_context *ctx)
 	if (gset_changed) {
 		struct ethtool_cmd ecmd;
 
+		memset(&ecmd, 0, sizeof(struct ethtool_cmd));
+
 		ecmd.cmd = ETHTOOL_GSET;
 		err = send_ioctl(ctx, &ecmd);
 		if (err < 0) {