netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH net-next] wireless: test sscanf return values
Date: Thu, 26 Feb 2015 21:43:11 -0800	[thread overview]
Message-ID: <1425015791.2690.7.camel@perches.com> (raw)

At some point, it'd be good to make sscanf use __must_check
so make sure the net/ uses of sscanf use the return value.

Signed-off-by: Joe Perches <joe@perches.com>
---

Compiled, untested.

 net/mac80211/debugfs.c | 4 ++--
 net/wireless/core.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index eeb0bbd..0e44be7 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -160,9 +160,9 @@ static ssize_t sta_tx_latency_stat_write(struct file *file,
 	tx_latency->n_ranges = n_ranges;
 	for (i = 0; i < n_ranges; i++) { /* setting bin ranges */
 		token = strsep(&bins, TX_LATENCY_BIN_DELIMTER_S);
-		sscanf(token, "%d", &tx_latency->ranges[i]);
 		/* bins values should be in ascending order */
-		if (prev_bin >= tx_latency->ranges[i]) {
+		if (sscanf(token, "%d", &tx_latency->ranges[i]) != 1 ||
+		    prev_bin >= tx_latency->ranges[i]) {
 			ret = -EINVAL;
 			kfree(tx_latency);
 			goto unlock;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 3af0ecf..69a350e 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -95,8 +95,8 @@ static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
 	ASSERT_RTNL();
 
 	/* prohibit calling the thing phy%d when %d is not its number */
-	sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
-	if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
+	if (sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken) == 1 &&
+	    taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
 		/* count number of places needed to print wiphy_idx */
 		digits = 1;
 		while (wiphy_idx /= 10)

             reply	other threads:[~2015-02-27  5:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27  5:43 Joe Perches [this message]
2015-02-27 10:35 ` [PATCH net-next] wireless: test sscanf return values David Laight
2015-02-27 12:36   ` Joe Perches

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=1425015791.2690.7.camel@perches.com \
    --to=joe@perches.com \
    --cc=davem@davemloft.net \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).