All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] nl80211: nl80211hdr_put() doesn't return an ERR_PTR
@ 2013-08-14 11:50 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-08-14 11:50 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John W. Linville, linux-wireless, kernel-janitors

There are a few places which check nl80211hdr_put() for an ERR_PTR
but actually it returns NULL on error and never error values.  In
nl80211_testmode_dump() the return wasn't checked at all so I have added
one.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is static checker stuff and I don't know the code well.  I was
especially not sure if I got the check right in nl80211_testmode_dump().
Please review that bit carefully.

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index adf1e98..47b8ac5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2664,8 +2664,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
 
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_NEW_KEY);
-	if (IS_ERR(hdr))
-		return PTR_ERR(hdr);
+	if (!hdr)
+		return -ENOBUFS;
 
 	cookie.msg = msg;
 	cookie.idx = key_idx;
@@ -6665,10 +6665,14 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
 	}
 
 	while (1) {
-		void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
+		void *hdr;
+		struct nlattr *tmdata;
+
+		hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
 					   cb->nlh->nlmsg_seq, NLM_F_MULTI,
 					   NL80211_CMD_TESTMODE);
-		struct nlattr *tmdata;
+		if (!hdr)
+			break;
 
 		if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
 			genlmsg_cancel(skb, hdr);
@@ -7115,8 +7119,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_REMAIN_ON_CHANNEL);
 
-	if (IS_ERR(hdr)) {
-		err = PTR_ERR(hdr);
+	if (!hdr) {
+		err = -ENOBUFS;
 		goto free_msg;
 	}
 
@@ -7415,8 +7419,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
 		hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 				     NL80211_CMD_FRAME);
 
-		if (IS_ERR(hdr)) {
-			err = PTR_ERR(hdr);
+		if (!hdr) {
+			err = -ENOBUFS;
 			goto free_msg;
 		}
 	}
@@ -8552,8 +8556,8 @@ static int nl80211_probe_client(struct sk_buff *skb,
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_PROBE_CLIENT);
 
-	if (IS_ERR(hdr)) {
-		err = PTR_ERR(hdr);
+	if (!hdr) {
+		err = -ENOBUFS;
 		goto free_msg;
 	}
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] nl80211: nl80211hdr_put() doesn't return an ERR_PTR
@ 2013-08-14 11:50 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-08-14 11:50 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John W. Linville, linux-wireless, kernel-janitors

There are a few places which check nl80211hdr_put() for an ERR_PTR
but actually it returns NULL on error and never error values.  In
nl80211_testmode_dump() the return wasn't checked at all so I have added
one.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is static checker stuff and I don't know the code well.  I was
especially not sure if I got the check right in nl80211_testmode_dump().
Please review that bit carefully.

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index adf1e98..47b8ac5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2664,8 +2664,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
 
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_NEW_KEY);
-	if (IS_ERR(hdr))
-		return PTR_ERR(hdr);
+	if (!hdr)
+		return -ENOBUFS;
 
 	cookie.msg = msg;
 	cookie.idx = key_idx;
@@ -6665,10 +6665,14 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
 	}
 
 	while (1) {
-		void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
+		void *hdr;
+		struct nlattr *tmdata;
+
+		hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
 					   cb->nlh->nlmsg_seq, NLM_F_MULTI,
 					   NL80211_CMD_TESTMODE);
-		struct nlattr *tmdata;
+		if (!hdr)
+			break;
 
 		if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
 			genlmsg_cancel(skb, hdr);
@@ -7115,8 +7119,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_REMAIN_ON_CHANNEL);
 
-	if (IS_ERR(hdr)) {
-		err = PTR_ERR(hdr);
+	if (!hdr) {
+		err = -ENOBUFS;
 		goto free_msg;
 	}
 
@@ -7415,8 +7419,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
 		hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 				     NL80211_CMD_FRAME);
 
-		if (IS_ERR(hdr)) {
-			err = PTR_ERR(hdr);
+		if (!hdr) {
+			err = -ENOBUFS;
 			goto free_msg;
 		}
 	}
@@ -8552,8 +8556,8 @@ static int nl80211_probe_client(struct sk_buff *skb,
 	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
 			     NL80211_CMD_PROBE_CLIENT);
 
-	if (IS_ERR(hdr)) {
-		err = PTR_ERR(hdr);
+	if (!hdr) {
+		err = -ENOBUFS;
 		goto free_msg;
 	}
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] nl80211: nl80211hdr_put() doesn't return an ERR_PTR
  2013-08-14 11:50 ` Dan Carpenter
@ 2013-08-14 11:56   ` Johannes Berg
  -1 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2013-08-14 11:56 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: John W. Linville, linux-wireless, kernel-janitors

On Wed, 2013-08-14 at 14:50 +0300, Dan Carpenter wrote:
> There are a few places which check nl80211hdr_put() for an ERR_PTR
> but actually it returns NULL on error and never error values.  In
> nl80211_testmode_dump() the return wasn't checked at all so I have added
> one.

Err, wow. How did we do this?!

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This is static checker stuff and I don't know the code well.  I was
> especially not sure if I got the check right in nl80211_testmode_dump().
> Please review that bit carefully.

Yes, looks fine. I'll apply this for 3.11, thanks.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] nl80211: nl80211hdr_put() doesn't return an ERR_PTR
@ 2013-08-14 11:56   ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2013-08-14 11:56 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: John W. Linville, linux-wireless, kernel-janitors

On Wed, 2013-08-14 at 14:50 +0300, Dan Carpenter wrote:
> There are a few places which check nl80211hdr_put() for an ERR_PTR
> but actually it returns NULL on error and never error values.  In
> nl80211_testmode_dump() the return wasn't checked at all so I have added
> one.

Err, wow. How did we do this?!

> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This is static checker stuff and I don't know the code well.  I was
> especially not sure if I got the check right in nl80211_testmode_dump().
> Please review that bit carefully.

Yes, looks fine. I'll apply this for 3.11, thanks.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-14 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-14 11:50 [patch] nl80211: nl80211hdr_put() doesn't return an ERR_PTR Dan Carpenter
2013-08-14 11:50 ` Dan Carpenter
2013-08-14 11:56 ` Johannes Berg
2013-08-14 11:56   ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.