aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ks7010/ks_wlan_net.c
diff options
context:
space:
mode:
authorSergio Paracuellos <sergio.paracuellos@gmail.com>2018-04-19 07:07:57 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-23 14:32:04 +0200
commitfffe8becb7cf67c78f954721689e6906cc936c68 (patch)
tree7618252bffea1d66047c024340f952abdf4233d1 /drivers/staging/ks7010/ks_wlan_net.c
parentstaging: ks7010: remove not used enum in eap_packet header file (diff)
downloadlinux-dev-fffe8becb7cf67c78f954721689e6906cc936c68.tar.xz
linux-dev-fffe8becb7cf67c78f954721689e6906cc936c68.zip
staging: ks7010: remove auxiliar zeros buffer in ks_wlan_get_encode
This commit removes the local buffer zeros in ks_wlan_get_encode function. It also refactors related conditions in order to fill 'extra' output parameter of the function. Originally this zeros is just memset to zeros and only being used if drw->length is truncated to zero because of priv->reg.wep_key[index].size is greater than 16 chars. In those cases the final if statement is just using zeros but it is using memcpy with a length of zero bytes which has no sense. Instead of that just handle the good case copying from the same source the number of bytes of priv->reg.wep_key[index].size. If it is zero the final 'extra' parameter won't be copied at all because the number of bytes to copy will be zero. With this change the code gets simplified. Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/ks7010/ks_wlan_net.c')
-rw-r--r--drivers/staging/ks7010/ks_wlan_net.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index eaee49d76dff..d0350a2c527e 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -932,7 +932,6 @@ static int ks_wlan_get_encode(struct net_device *dev,
struct iw_point *dwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- char zeros[16];
int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
if (priv->sleep_mode == SLP_SLEEP)
@@ -951,8 +950,6 @@ static int ks_wlan_get_encode(struct net_device *dev,
break;
}
- memset(zeros, 0, sizeof(zeros));
-
/* Which key do we want ? -1 -> tx index */
if ((index < 0) || (index >= 4))
index = priv->reg.wep_index;
@@ -962,16 +959,10 @@ static int ks_wlan_get_encode(struct net_device *dev,
}
dwrq->flags |= index + 1;
/* Copy the key to the user buffer */
- if ((index >= 0) && (index < 4))
- dwrq->length = priv->reg.wep_key[index].size;
- if (dwrq->length > 16)
- dwrq->length = 0;
- if (dwrq->length) {
- if ((index >= 0) && (index < 4))
- memcpy(extra, priv->reg.wep_key[index].val,
- dwrq->length);
- } else {
- memcpy(extra, zeros, dwrq->length);
+ if (index >= 0 && index < 4) {
+ dwrq->length = (priv->reg.wep_key[index].size <= 16) ?
+ priv->reg.wep_key[index].size : 0;
+ memcpy(extra, priv->reg.wep_key[index].val, dwrq->length);
}
return 0;