From: Wei Yongjun <weiyongj...@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 <weiyongj...@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)

Reply via email to