diff mbox

[net] ieee802154: fix logic error in ieee802154_llsec_parse_dev_addr

Message ID 7c36848d-28b5-87cc-f998-53cc2428a0a6@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Baozeng May 26, 2016, 1:07 p.m. UTC
Fix a logic error to avoid potential null pointer dereference.

Signed-off-by: Baozeng Ding <sploving1@gmail.com>
---
 net/ieee802154/nl802154.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefan Schmidt May 27, 2016, 10:24 a.m. UTC | #1
Hello.

On 26/05/16 15:07, Baozeng Ding wrote:
> Fix a logic error to avoid potential null pointer dereference.
>
> Signed-off-by: Baozeng Ding<sploving1@gmail.com>
> ---
>   net/ieee802154/nl802154.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
> index ca207db..116187b 100644
> --- a/net/ieee802154/nl802154.c
> +++ b/net/ieee802154/nl802154.c
> @@ -1289,8 +1289,8 @@ ieee802154_llsec_parse_dev_addr(struct nlattr *nla,
>   				     nl802154_dev_addr_policy))
>   		return -EINVAL;
>   
> -	if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] &&
> -	    !attrs[NL802154_DEV_ADDR_ATTR_MODE] &&
> +	if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] ||
> +	    !attrs[NL802154_DEV_ADDR_ATTR_MODE] ||
>   	    !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] ||
>   	      attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]))
>   		return -EINVAL;

Good catch!

Reviewed-by: Stefan Schmidt<stefan@osg.samsung.com>

regards
Stefan Schmidt
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 30, 2016, 5:36 a.m. UTC | #2
From: Baozeng Ding <sploving1@gmail.com>
Date: Thu, 26 May 2016 21:07:42 +0800

> Fix a logic error to avoid potential null pointer dereference.
> 
> Signed-off-by: Baozeng Ding <sploving1@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c
index ca207db..116187b 100644
--- a/net/ieee802154/nl802154.c
+++ b/net/ieee802154/nl802154.c
@@ -1289,8 +1289,8 @@  ieee802154_llsec_parse_dev_addr(struct nlattr *nla,
 				     nl802154_dev_addr_policy))
 		return -EINVAL;
 
-	if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] &&
-	    !attrs[NL802154_DEV_ADDR_ATTR_MODE] &&
+	if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] ||
+	    !attrs[NL802154_DEV_ADDR_ATTR_MODE] ||
 	    !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] ||
 	      attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]))
 		return -EINVAL;