Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 328eff75 authored by Dan Carpenter's avatar Dan Carpenter Committed by Ahmad Kholaif
Browse files

nl80211: nl80211hdr_put() doesn't return an ERR_PTR



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: default avatarDan Carpenter <dan.carpenter@oracle.com>
[some whitespace changes]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Git-commit: cb35fba360dfc3496e5d8a47e23ec5ccdfd90925
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Change-Id: I5da1aafea35110a1ce606d402b1b96859d34b869
Signed-off-by: default avatarAhmad Kholaif <akholaif@codeaurora.org>
parent 158da626
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -2672,8 +2672,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,
	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
			     NL80211_CMD_NEW_KEY);
			     NL80211_CMD_NEW_KEY);
	if (IS_ERR(hdr))
	if (!hdr)
		return PTR_ERR(hdr);
		return -ENOBUFS;


	cookie.msg = msg;
	cookie.msg = msg;
	cookie.idx = key_idx;
	cookie.idx = key_idx;
@@ -6698,6 +6698,9 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
					   NL80211_CMD_TESTMODE);
					   NL80211_CMD_TESTMODE);
		struct nlattr *tmdata;
		struct nlattr *tmdata;


		if (!hdr)
			break;

		if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
		if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
			genlmsg_cancel(skb, hdr);
			genlmsg_cancel(skb, hdr);
			break;
			break;
@@ -7099,9 +7102,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,


	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
			     NL80211_CMD_REMAIN_ON_CHANNEL);
			     NL80211_CMD_REMAIN_ON_CHANNEL);

	if (!hdr) {
	if (IS_ERR(hdr)) {
		err = -ENOBUFS;
		err = PTR_ERR(hdr);
		goto free_msg;
		goto free_msg;
	}
	}


@@ -7388,9 +7390,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,
		hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
				     NL80211_CMD_FRAME);
				     NL80211_CMD_FRAME);

		if (!hdr) {
		if (IS_ERR(hdr)) {
			err = -ENOBUFS;
			err = PTR_ERR(hdr);
			goto free_msg;
			goto free_msg;
		}
		}
	}
	}
@@ -8251,9 +8252,8 @@ static int nl80211_probe_client(struct sk_buff *skb,


	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
	hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
			     NL80211_CMD_PROBE_CLIENT);
			     NL80211_CMD_PROBE_CLIENT);

	if (!hdr) {
	if (IS_ERR(hdr)) {
		err = -ENOBUFS;
		err = PTR_ERR(hdr);
		goto free_msg;
		goto free_msg;
	}
	}