Hello Maintainers:

Please help check this patch, when you have time.

Thanks.

On 07/11/2013 12:06 PM, Chen Gang wrote:
> When sysfs_create_file() fails, need consider about it. And process it
> with BUG_ON(), because sysfs_create_file() can fail due to OOM (not at
> boot) or name duplication (not here).
> 
> Also correct the error printing information when failure occurs.
> 
> Signed-off-by: Chen Gang <gang.c...@asianux.com>
> ---
>  kernel/params.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/params.c b/kernel/params.c
> index 440e65d..3d70f90 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -745,12 +745,14 @@ static struct module_kobject * __init 
> locate_module_kobject(const char *name)
>               err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL,
>                                          "%s", name);
>  #ifdef CONFIG_MODULES
> -             if (!err)
> +             if (!err) {
>                       err = sysfs_create_file(&mk->kobj, &module_uevent.attr);
> +                     BUG_ON(err);
> +             }
>  #endif
>               if (err) {
>                       kobject_put(&mk->kobj);
> -                     pr_crit("Adding module '%s' to sysfs failed (%d), the 
> system may be unstable.\n",
> +                     pr_crit("Initializing and adding module '%s' failed 
> (%d), the system may be unstable.\n",
>                               name, err);
>                       return NULL;
>               }
> @@ -845,6 +847,7 @@ static void __init version_sysfs_builtin(void)
>               mk = locate_module_kobject(vattr->module_name);
>               if (mk) {
>                       err = sysfs_create_file(&mk->kobj, &vattr->mattr.attr);
> +                     BUG_ON(err);
>                       kobject_uevent(&mk->kobj, KOBJ_ADD);
>                       kobject_put(&mk->kobj);
>               }
> 


-- 
Chen Gang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to