* [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call
@ 2016-03-15 19:53 Claudiu Beznea
2016-03-22 2:02 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Beznea @ 2016-03-15 19:53 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel, Claudiu Beznea
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(ðcmd, 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call
2016-03-15 19:53 [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call Claudiu Beznea
@ 2016-03-22 2:02 ` Greg KH
[not found] ` <CAJSSEVxOjKtcvu8fpy2ghtG1haL80-r3SY-YQO2EuwDza94__Q@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2016-03-22 2:02 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: devel, linux-kernel
On Tue, Mar 15, 2016 at 09:53:15PM +0200, Claudiu Beznea wrote:
> 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.
Does that really matter? If an error happens, then we are on a "slow
path" and the extra memset didn't matter at all. Don't move code around
for no good reason, and if you think it makes things faster, then you
have to be able to prove it somehow :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call
[not found] ` <CAJSSEVxOjKtcvu8fpy2ghtG1haL80-r3SY-YQO2EuwDza94__Q@mail.gmail.com>
@ 2016-03-22 13:27 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2016-03-22 13:27 UTC (permalink / raw)
To: Claudiu Beznea; +Cc: devel, linux-kernel
On Tue, Mar 22, 2016 at 03:02:00PM +0200, Claudiu Beznea wrote:
> I was guided by the principle that every instruction counts, no matter the
> execution context.
But you have to be able to actually measure the difference, and here you
can't.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-22 13:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-15 19:53 [PATCH] Staging: wlan-ng: moved memset() calls after copy_from_user() call Claudiu Beznea
2016-03-22 2:02 ` Greg KH
[not found] ` <CAJSSEVxOjKtcvu8fpy2ghtG1haL80-r3SY-YQO2EuwDza94__Q@mail.gmail.com>
2016-03-22 13:27 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox