Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1519080 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2016-11-10 17:00 +0100 |
| Last post | 2016-11-10 18:20 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] genetlink: fix unsigned int comparison with less than zero Colin King <colin.king@canonical.com> - 2016-11-10 17:00 +0100
Re: [PATCH] genetlink: fix unsigned int comparison with less than zero Cong Wang <xiyou.wangcong@gmail.com> - 2016-11-10 18:20 +0100
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2016-11-10 17:00 +0100 |
| Subject | [PATCH] genetlink: fix unsigned int comparison with less than zero |
| Message-ID | <sBZVD-8ak-7@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Cong Wang <xiyou.wangcong@gmail.com> |
|---|---|
| Date | 2016-11-10 18:20 +0100 |
| Message-ID | <sC1b3-FQ-3@gated-at.bofh.it> |
| In reply to | #1519080 |
On Thu, Nov 10, 2016 at 7:57 AM, Colin King <colin.king@canonical.com> wrote: > 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. Why family->id can't be just signed int? For me it should be.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web