mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: khali@linux-fr.org, David.Woodhouse@intel.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] kernel/params.c: add/modify failure processing code when sysfs_create_file() fails.
Date: Mon, 22 Jul 2013 10:41:58 +0800	[thread overview]
Message-ID: <51EC9BF6.3060800@asianux.com> (raw)
In-Reply-To: <51DE2F55.2070109@asianux.com>

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

      reply	other threads:[~2013-07-22  2:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09  3:37 [PATCH] kernel/params.c: print failure information instead of 'KOBJ_ADD' to user space, " Chen Gang
2013-07-09  8:07 ` Rusty Russell
2013-07-10  2:17   ` Chen Gang F T
2013-07-10  2:35     ` Chen Gang
2013-07-10  3:01       ` Chen Gang F T
2013-07-11 23:45         ` Chen Gang
2013-07-11  1:53     ` Rusty Russell
2013-07-11  2:57       ` Chen Gang
2013-07-11  4:06       ` [PATCH v2] kernel/params.c: add/modify failure processing code " Chen Gang
2013-07-22  2:41         ` Chen Gang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51EC9BF6.3060800@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=David.Woodhouse@intel.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome