From: Wei Yongjun <weiyj...@gmail.com>
Date: Mon, 31 Oct 2016 14:53:03 +0000

> 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>
 ...
> @@ -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).

Reply via email to