Linux wireless drivers development
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com,
	cjhuang@codeaurora.org
Subject: [PATCH mac80211] cfg80211: check nla_parse_nested return code in nl80211_set_sar_specs
Date: Sun, 21 Nov 2021 12:41:56 +0100	[thread overview]
Message-ID: <3b6fee130e2d264242463cff063bcfb6d6f5da83.1637494779.git.lorenzo@kernel.org> (raw)

Check error code returned by nla_parse_nested in nl80211_set_sar_specs
routine before parsing SAR sub-specs.

Fixes: 6bdb68cef7bf5 ("nl80211: add common API to configure SAR power limitations")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 net/wireless/nl80211.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a27b3b5fa210..c2b005d0d29a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -15294,9 +15294,11 @@ static int nl80211_set_sar_specs(struct sk_buff *skb, struct genl_info *info)
 	if (!info->attrs[NL80211_ATTR_SAR_SPEC])
 		return -EINVAL;
 
-	nla_parse_nested(tb, NL80211_SAR_ATTR_MAX,
-			 info->attrs[NL80211_ATTR_SAR_SPEC],
-			 NULL, NULL);
+	err = nla_parse_nested(tb, NL80211_SAR_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_SAR_SPEC],
+			       NULL, NULL);
+	if (err)
+		return err;
 
 	if (!tb[NL80211_SAR_ATTR_TYPE] || !tb[NL80211_SAR_ATTR_SPECS])
 		return -EINVAL;
@@ -15319,16 +15321,17 @@ static int nl80211_set_sar_specs(struct sk_buff *skb, struct genl_info *info)
 	sar_spec->type = type;
 	specs = 0;
 	nla_for_each_nested(spec_list, tb[NL80211_SAR_ATTR_SPECS], rem) {
-		nla_parse_nested(spec, NL80211_SAR_ATTR_SPECS_MAX,
-				 spec_list, NULL, NULL);
+		err = nla_parse_nested(spec, NL80211_SAR_ATTR_SPECS_MAX,
+				       spec_list, NULL, NULL);
+		if (err)
+			goto error;
 
 		switch (type) {
 		case NL80211_SAR_TYPE_POWER:
-			if (nl80211_set_sar_sub_specs(rdev, sar_spec,
-						      spec, specs)) {
-				err = -EINVAL;
+			err = nl80211_set_sar_sub_specs(rdev, sar_spec, spec,
+							specs);
+			if (err)
 				goto error;
-			}
 			break;
 		default:
 			err = -EINVAL;
-- 
2.31.1


             reply	other threads:[~2021-11-21 11:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 11:41 Lorenzo Bianconi [this message]
2021-11-22  8:18 ` [PATCH mac80211] cfg80211: check nla_parse_nested return code in nl80211_set_sar_specs Johannes Berg
2021-11-22 10:58   ` Lorenzo Bianconi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3b6fee130e2d264242463cff063bcfb6d6f5da83.1637494779.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=cjhuang@codeaurora.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox