From patchwork Fri May 22 22:43:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Parameswaran X-Patchwork-Id: 475828 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9105D140E45 for ; Sat, 23 May 2015 08:43:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422845AbbEVWnh (ORCPT ); Fri, 22 May 2015 18:43:37 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:35346 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756896AbbEVWng (ORCPT ); Fri, 22 May 2015 18:43:36 -0400 X-IronPort-AV: E=Sophos;i="5.13,478,1427785200"; d="scan'208";a="65785117" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 22 May 2015 16:23:48 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 22 May 2015 15:43:33 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.235.1; Fri, 22 May 2015 15:43:33 -0700 Received: from localhost.localdomain (unknown [10.136.4.147]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id DCBF240FE8; Fri, 22 May 2015 15:41:48 -0700 (PDT) From: Arun Parameswaran To: Ben Hutchings CC: , , Subject: [PATCH 1/2] ethtool: Clear the command data structure before sending requests Date: Fri, 22 May 2015 15:43:28 -0700 Message-ID: <1432334609-3971-2-git-send-email-aparames@broadcom.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1432334609-3971-1-git-send-email-aparames@broadcom.com> References: <1432334609-3971-1-git-send-email-aparames@broadcom.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: JD (Jiandong) Zheng --- ethtool.c | 3 +++ 1 file changed, 3 insertions(+) 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) {