aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2011-01-28 09:17:11 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-01-28 15:46:23 -0500
commitefe1cf0c5743caf4daccb57b399ef63edad41c9d (patch)
treed482979aa5a16a49d8095dcf00b6023c9051b86f /net/wireless/nl80211.c
parent76a9f6fd9adc5ce62b4ea36a099bb1458d4cb7a6 (diff)
net/wireless/nl80211.c: Avoid call to genlmsg_cancel
genlmsg_cancel subtracts some constants from its second argument before calling nlmsg_cancel. nlmsg_cancel then calls nlmsg_trim on the same arguments. nlmsg_trim tests for NULL before doing any computation, but a NULL second argument to genlmsg_cancel is no longer NULL due to the initial subtraction. Nothing else happens in this execution, so the call to genlmsg_cancel is simply unnecessary in this case. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression data; @@ if (data == NULL) { ... * genlmsg_cancel(..., data); ... return ...; } // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 9b62710891a2..864ddfbeff2f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2718,7 +2718,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
2718 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, 2718 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
2719 NL80211_CMD_GET_MESH_CONFIG); 2719 NL80211_CMD_GET_MESH_CONFIG);
2720 if (!hdr) 2720 if (!hdr)
2721 goto nla_put_failure; 2721 goto out;
2722 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG); 2722 pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG);
2723 if (!pinfoattr) 2723 if (!pinfoattr)
2724 goto nla_put_failure; 2724 goto nla_put_failure;
@@ -2759,6 +2759,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
2759 2759
2760 nla_put_failure: 2760 nla_put_failure:
2761 genlmsg_cancel(msg, hdr); 2761 genlmsg_cancel(msg, hdr);
2762 out:
2762 nlmsg_free(msg); 2763 nlmsg_free(msg);
2763 return -ENOBUFS; 2764 return -ENOBUFS;
2764} 2765}
@@ -2954,7 +2955,7 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
2954 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, 2955 hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
2955 NL80211_CMD_GET_REG); 2956 NL80211_CMD_GET_REG);
2956 if (!hdr) 2957 if (!hdr)
2957 goto nla_put_failure; 2958 goto put_failure;
2958 2959
2959 NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2, 2960 NLA_PUT_STRING(msg, NL80211_ATTR_REG_ALPHA2,
2960 cfg80211_regdomain->alpha2); 2961 cfg80211_regdomain->alpha2);
@@ -3001,6 +3002,7 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
3001 3002
3002nla_put_failure: 3003nla_put_failure:
3003 genlmsg_cancel(msg, hdr); 3004 genlmsg_cancel(msg, hdr);
3005put_failure:
3004 nlmsg_free(msg); 3006 nlmsg_free(msg);
3005 err = -EMSGSIZE; 3007 err = -EMSGSIZE;
3006out: 3008out: