Skip to content

Commit

Permalink
genetlink: fix error return code in genl_register_family()
Browse files Browse the repository at this point in the history
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: 2ae0f17 ("genetlink: use idr to track families")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wei Yongjun authored and David S. Miller committed Nov 1, 2016
1 parent e58e415 commit 22ca904
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 22ca904

Please sign in to comment.