Skip to content

Commit 22ca904

Browse files
Wei Yongjundavem330
authored andcommitted
genetlink: fix error return code in genl_register_family()
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e58e415 commit 22ca904

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/netlink/genetlink.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ int genl_register_family(struct genl_family *family)
362362

363363
family->id = idr_alloc(&genl_fam_idr, family,
364364
start, end + 1, GFP_KERNEL);
365-
if (!family->id)
365+
if (family->id < 0) {
366+
err = family->id;
366367
goto errout_locked;
368+
}
367369

368370
err = genl_validate_assign_mc_groups(family);
369371
if (err)

0 commit comments

Comments
 (0)