From: Colin King <colin.king@canonical.com>
To: "David S . Miller" <davem@davemloft.net>,
Johannes Berg <johannes.berg@intel.com>,
pravin shelar <pshelar@ovn.org>,
Wei Yongjun <weiyongjun1@huawei.com>,
Florian Westphal <fw@strlen.de>,
Tycho Andersen <tycho.andersen@canonical.com>,
WANG Cong <xiyou.wangcong@gmail.com>,
Tom Herbert <tom@herbertland.com>,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] genetlink: fix unsigned int comparison with less than zero
Date: Thu, 10 Nov 2016 15:57:58 +0000 [thread overview]
Message-ID: <20161110155758.26996-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
family->id is unsigned, so the less than zero check for
failure return from idr_alloc is never true and so the error exit
is never handled. Instead, assign err and check if this is less
than zero since this is a signed integer.
Issue found with static analysis with CoverityScan, CID 1375916
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/netlink/genetlink.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index f0b65fe..2ea61ba 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -360,12 +360,10 @@ int genl_register_family(struct genl_family *family)
} else
family->attrbuf = NULL;
- family->id = idr_alloc(&genl_fam_idr, family,
+ family->id = err = idr_alloc(&genl_fam_idr, family,
start, end + 1, GFP_KERNEL);
- if (family->id < 0) {
- err = family->id;
+ if (err < 0)
goto errout_free;
- }
err = genl_validate_assign_mc_groups(family);
if (err)
--
2.10.2
next reply other threads:[~2016-11-10 15:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-10 15:57 Colin King [this message]
2016-11-10 17:11 ` [PATCH] genetlink: fix unsigned int comparison with less than zero Cong Wang
2016-11-12 21:37 ` Johannes Berg
2016-11-13 5:25 ` Cong Wang
2016-11-13 7:31 ` Johannes Berg
2016-11-13 17:15 ` David Miller
2016-11-14 6:29 ` Cong Wang
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=20161110155758.26996-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pshelar@ovn.org \
--cc=tom@herbertland.com \
--cc=tycho.andersen@canonical.com \
--cc=weiyongjun1@huawei.com \
--cc=xiyou.wangcong@gmail.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;
as well as URLs for NNTP newsgroup(s).