* [PATCH net-next] genetlink: fix error return code in genl_register_family()
@ 2016-10-31 14:53 Wei Yongjun
2016-10-31 20:29 ` David Miller
2016-11-01 14:45 ` [PATCH net-next v2] " Wei Yongjun
0 siblings, 2 replies; 4+ messages in thread
From: Wei Yongjun @ 2016-10-31 14:53 UTC (permalink / raw)
To: stephen hemminger, Matti Vaittinen, Tom Herbert, Johannes Berg,
pravin shelar, Tycho Andersen, Florian Westphal
Cc: Wei Yongjun, netdev
From: Wei Yongjun <weiyongjun1@huawei.com>
Fix to return error code -ENOMEM from the idr_alloc() error handling
case instead of 0, as done elsewhere in this function.
Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
net/netlink/genetlink.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index caf04d7..305730d 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -362,8 +362,10 @@ int genl_register_family(struct genl_family *family)
family->id = idr_alloc(&genl_fam_idr, family,
start, end + 1, GFP_KERNEL);
- if (!family->id)
+ if (!family->id) {
+ err = -ENOMEM;
goto errout_locked;
+ }
err = genl_validate_assign_mc_groups(family);
if (err)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] genetlink: fix error return code in genl_register_family()
2016-10-31 14:53 [PATCH net-next] genetlink: fix error return code in genl_register_family() Wei Yongjun
@ 2016-10-31 20:29 ` David Miller
2016-11-01 14:45 ` [PATCH net-next v2] " Wei Yongjun
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-10-31 20:29 UTC (permalink / raw)
To: weiyj.lk
Cc: stephen, matti.vaittinen, tom, johannes.berg, pshelar,
tycho.andersen, fw, weiyongjun1, netdev
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Mon, 31 Oct 2016 14:53:03 +0000
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> Fix to return error code -ENOMEM from the idr_alloc() error handling
> case instead of 0, as done elsewhere in this function.
>
> Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
...
> @@ -362,8 +362,10 @@ int genl_register_family(struct genl_family *family)
>
> family->id = idr_alloc(&genl_fam_idr, family,
> start, end + 1, GFP_KERNEL);
> - if (!family->id)
> + if (!family->id) {
> + err = -ENOMEM;
> goto errout_locked;
> + }
>
> err = genl_validate_assign_mc_groups(family);
> if (err)
idr_alloc() returns negative error codes, not zero, on failure.
So we should return whatever idr_alloc() returns because it has
at least two error return cases (ENOSPC and ENOMEM).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2] genetlink: fix error return code in genl_register_family()
2016-10-31 14:53 [PATCH net-next] genetlink: fix error return code in genl_register_family() Wei Yongjun
2016-10-31 20:29 ` David Miller
@ 2016-11-01 14:45 ` Wei Yongjun
2016-11-01 16:13 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Wei Yongjun @ 2016-11-01 14:45 UTC (permalink / raw)
To: David S . Miller, stephen hemminger, Tom Herbert,
Florian Westphal, Johannes Berg, pravin shelar, Tycho Andersen,
Matti Vaittinen
Cc: Wei Yongjun, netdev
From: Wei Yongjun <weiyongjun1@huawei.com>
Fix to return a negative error code from the idr_alloc() error handling
case instead of 0, as done elsewhere in this function.
Also fix the return value check of idr_alloc() since idr_alloc return
negative errors on failure, not zero.
Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
v1 -> v2: fix the return value check and return idr_alloc's err code
---
net/netlink/genetlink.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index caf04d7..bbd3bff 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -362,8 +362,10 @@ int genl_register_family(struct genl_family *family)
family->id = idr_alloc(&genl_fam_idr, family,
start, end + 1, GFP_KERNEL);
- if (!family->id)
+ if (family->id < 0) {
+ err = family->id;
goto errout_locked;
+ }
err = genl_validate_assign_mc_groups(family);
if (err)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2] genetlink: fix error return code in genl_register_family()
2016-11-01 14:45 ` [PATCH net-next v2] " Wei Yongjun
@ 2016-11-01 16:13 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-11-01 16:13 UTC (permalink / raw)
To: weiyj.lk
Cc: stephen, tom, fw, johannes.berg, pshelar, tycho.andersen,
matti.vaittinen, weiyongjun1, netdev
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Tue, 1 Nov 2016 14:45:52 +0000
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> Fix to return a negative error code from the idr_alloc() error handling
> case instead of 0, as done elsewhere in this function.
>
> Also fix the return value check of idr_alloc() since idr_alloc return
> negative errors on failure, not zero.
>
> Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: fix the return value check and return idr_alloc's err code
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-01 16:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 14:53 [PATCH net-next] genetlink: fix error return code in genl_register_family() Wei Yongjun
2016-10-31 20:29 ` David Miller
2016-11-01 14:45 ` [PATCH net-next v2] " Wei Yongjun
2016-11-01 16:13 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.