Skip to content

Commit

Permalink
staging: ks7010: move null check before dereference
Browse files Browse the repository at this point in the history
Function parameter is cast to a local pointer which is then
dereferenced before it is checked to be non-NULL.

Move pointer null check to be before the pointer is dereferenced.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tobin C. Harding authored and Greg Kroah-Hartman committed Apr 11, 2017
1 parent dc59ef2 commit 9ff19a6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/staging/ks7010/ks_wlan_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,8 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
unsigned int commit = 0;

enc = (struct iw_encode_ext *)extra;
if (!enc)
return -EINVAL;

DPRINTK(2, "flags=%04X:: ext_flags=%08X\n", dwrq->flags,
enc->ext_flags);
Expand All @@ -1786,9 +1788,6 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
if (dwrq->flags & IW_ENCODE_DISABLED)
priv->wpa.key[index].key_len = 0;

if (!enc)
return -EINVAL;

priv->wpa.key[index].ext_flags = enc->ext_flags;
if (enc->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
priv->wpa.txkey = index;
Expand Down

0 comments on commit 9ff19a6

Please sign in to comment.