[PATCH 04/10] kobject: kobj->k_name verification fix

2007-02-16 Thread Greg Kroah-Hartman
From: Martin Stoilov <[EMAIL PROTECTED]>

The function 'kobject_add' tries to verify the name of
a new kobject instance is properly set before continuing.
if (!kobj->k_name)
kobj->k_name = kobj->name;
if (!kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
}
The statement:
if (!kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
}
is useless the way it is right now, because it can never be true. I
think the
code was intended to be:
if (!kobj->k_name)
kobj->k_name = kobj->name;
if (!*kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
}
because this would make sure the kobj->name buffer has something in it.
So the missing '*' is just a typo. Although, I would much prefer
expression like:
if (*kobj->k_name == '\0') {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
}

because this would've made the intention clear, in this patch I just restore
the missing '*' without changing the coding style of the function.

Signed-off-by: Martin Stoilov <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 lib/kobject.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 2782f49..93685f4 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -171,7 +171,7 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry 
*shadow_parent)
return -ENOENT;
if (!kobj->k_name)
kobj->k_name = kobj->name;
-   if (!kobj->k_name) {
+   if (!*kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
return -EINVAL;
-- 
1.5.0

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


[PATCH 04/10] kobject: kobj-k_name verification fix

2007-02-16 Thread Greg Kroah-Hartman
From: Martin Stoilov [EMAIL PROTECTED]

The function 'kobject_add' tries to verify the name of
a new kobject instance is properly set before continuing.
if (!kobj-k_name)
kobj-k_name = kobj-name;
if (!kobj-k_name) {
pr_debug(kobject attempted to be registered with no name!\n);
WARN_ON(1);
return -EINVAL;
}
The statement:
if (!kobj-k_name) {
pr_debug(kobject attempted to be registered with no name!\n);
WARN_ON(1);
return -EINVAL;
}
is useless the way it is right now, because it can never be true. I
think the
code was intended to be:
if (!kobj-k_name)
kobj-k_name = kobj-name;
if (!*kobj-k_name) {
pr_debug(kobject attempted to be registered with no name!\n);
WARN_ON(1);
return -EINVAL;
}
because this would make sure the kobj-name buffer has something in it.
So the missing '*' is just a typo. Although, I would much prefer
expression like:
if (*kobj-k_name == '\0') {
pr_debug(kobject attempted to be registered with no name!\n);
WARN_ON(1);
return -EINVAL;
}

because this would've made the intention clear, in this patch I just restore
the missing '*' without changing the coding style of the function.

Signed-off-by: Martin Stoilov [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Greg Kroah-Hartman [EMAIL PROTECTED]
---
 lib/kobject.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 2782f49..93685f4 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -171,7 +171,7 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry 
*shadow_parent)
return -ENOENT;
if (!kobj-k_name)
kobj-k_name = kobj-name;
-   if (!kobj-k_name) {
+   if (!*kobj-k_name) {
pr_debug(kobject attempted to be registered with no name!\n);
WARN_ON(1);
return -EINVAL;
-- 
1.5.0

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/