Re: [PATCH] kernel/params.c: print failure information instead of'KOBJ_ADD' to user space, when sysfs_create_file() fails.

From: Chen Gang
Date: Thu Jul 11 2013 - 19:46:48 EST


On 07/10/2013 11:01 AM, Chen Gang F T wrote:
>
>> > Hmm..., do we need call kobject_get() before kobject_put() in failure
>> > processing block ?
>> >
> Oh, sorry for what I said for kobject_get/put() items above, it is
> incorrect.
>
> What about the diff below for kobject_get() ?
>
> -------------------------------diff begin-------------------------------
>
> diff --git a/kernel/params.c b/kernel/params.c
> index 440e65d..ef8d720 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -754,11 +754,11 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
> name, err);
> return NULL;
> }
> -
> - /* So that we hold reference in both cases. */
> - kobject_get(&mk->kobj);
> }
>
> + /* So that we hold reference in both cases. */
> + kobject_get(&mk->kobj);
> +
> return mk;
> }
>
> -------------------------------diff end---------------------------------
>

Sorry again, this diff is incorrect, the original implementation has no
issues.


> And it also need add additional kobject_put(), if we really need
> process the failure in version_sysfs_builtin().

If need process failure, we really need it, but now, we only use
BUG_ON() is enough.


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