mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Claudiu Beznea <claudiu.beznea@gmail.com>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	Claudiu Beznea <claudiu.beznea@gmail.com>
Subject: [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call
Date: Tue, 15 Mar 2016 21:53:15 +0200	[thread overview]
Message-ID: <1458071595-22365-1-git-send-email-claudiu.beznea@gmail.com> (raw)

This patch moves memset() calls from p80211netdev_ethtool()
after copy_from_user() call in order to avoid unnecessary
instruction in case copy_from_user() fails.

Signed-off-by: Claudiu Beznea <claudiu.beznea@gmail.com>
---
 drivers/staging/wlan-ng/p80211netdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 88255ce..3723b8c 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -465,12 +465,12 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
 	struct ethtool_drvinfo info;
 	struct ethtool_value edata;
 
-	memset(&info, 0, sizeof(info));
-	memset(&edata, 0, sizeof(edata));
-
 	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
 		return -EFAULT;
 
+	memset(&info, 0, sizeof(info));
+	memset(&edata, 0, sizeof(edata));
+
 	switch (ethcmd) {
 	case ETHTOOL_GDRVINFO:
 		info.cmd = ethcmd;
-- 
1.9.1

             reply	other threads:[~2016-03-15 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 19:53 Claudiu Beznea [this message]
2016-03-22  2:02 ` Greg KH
     [not found]   ` <CAJSSEVxOjKtcvu8fpy2ghtG1haL80-r3SY-YQO2EuwDza94__Q@mail.gmail.com>
2016-03-22 13:27     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458071595-22365-1-git-send-email-claudiu.beznea@gmail.com \
    --to=claudiu.beznea@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®