]> git.karo-electronics.de Git - linux-beck.git/commitdiff
genetlink: fix error return code in genl_register_family()
authorWei Yongjun <weiyongjun1@huawei.com>
Tue, 1 Nov 2016 14:45:52 +0000 (14:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Nov 2016 16:13:13 +0000 (12:13 -0400)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/genetlink.c

index caf04d70ba71941ab8309caf6efeca5c8f41e55e..bbd3bff885a1fa309f98982907f23a1984424de4 100644 (file)
@@ -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)