Re: [broken-out-2007-07-20-00-22] kernel bug at kernel/params:570

Greg KH
2007-07-21T01:45:15Z

On Fri, Jul 20, 2007 at 06:37:33PM -0700, Andrew Morton wrote:
> On Fri, 20 Jul 2007 18:02:57 -0700 Greg KH <gregkh@suse.de> wrote:
>
> > --- a/kernel/params.c
> > +++ b/kernel/params.c
> > @@ -567,7 +567,11 @@ static void __init kernel_param_sysfs_se
> > kobject_set_name(&mk->kobj, name);
> > kobject_init(&mk->kobj);
> > ret = kobject_add(&mk->kobj);
> > - BUG_ON(ret < 0);
> > + if (ret) {
> > + printk(KERN_ERR "module '%s' failed to be added to sysfs, "
> > + "the system will be unstable now.\n", name);
> > + return;
> > + }
>
> It would be nice to print the value of `ret' too.

Ok, how about this version:

---
kernel/params.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

--- a/kernel/params.c
+++ b/kernel/params.c
@@ -567,7 +567,12 @@ static void __init kernel_param_sysfs_se
kobject_set_name(&mk->kobj, name);
kobject_init(&mk->kobj);
ret = kobject_add(&mk->kobj);
- BUG_ON(ret < 0);
+ if (ret) {
+ printk(KERN_ERR "Module '%s' failed to be added to sysfs, "
+ "error number %d\n", name, ret);
+ printk(KERN_ERR "The system will be unstable now.\n");
+ return;
+ }
param_sysfs_setup(mk, kparam, num_params, name_skip);
kobject_uevent(&mk->kobj, KOBJ_ADD);
}