LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Martin Stoilov <mstoilov@odesys.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 04/10] kobject: kobj->k_name verification fix
Date: Fri, 16 Feb 2007 15:37:30 -0800	[thread overview]
Message-ID: <11716690662679-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <11716690633694-git-send-email-gregkh@suse.de>

From: Martin Stoilov <mstoilov@odesys.com>

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 <mstoilov@odesys.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 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


  reply	other threads:[~2007-02-16 23:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 23:35 [GIT PATCH] more Driver core patches for 2.6.20 Greg KH
2007-02-16 23:37 ` [PATCH 01/10] Driver.h copyright update Greg Kroah-Hartman
2007-02-16 23:37   ` [PATCH 02/10] Driver core: let request_module() send a /sys/modules/kmod/-uevent Greg Kroah-Hartman
2007-02-16 23:37     ` [PATCH 03/10] serial: Add PCMCIA IDs for Quatech DSP-100 dual RS232 adapter Greg Kroah-Hartman
2007-02-16 23:37       ` Greg Kroah-Hartman [this message]
2007-02-16 23:37         ` [PATCH 05/10] Driver: remove redundant kobject_unregister checks Greg Kroah-Hartman
2007-02-16 23:37           ` [PATCH 06/10] debugfs: implement symbolic links Greg Kroah-Hartman
2007-02-16 23:37             ` [PATCH 07/10] debugfs: Remove misleading comments Greg Kroah-Hartman
2007-02-16 23:37               ` [PATCH 08/10] Driver core: device_add_attrs() cleanup Greg Kroah-Hartman
2007-02-16 23:37                 ` [PATCH 09/10] pcmcia: some class_device fallout Greg Kroah-Hartman
2007-02-16 23:37                   ` [PATCH 10/10] sysfs: fix build errors: uevent with CONFIG_SYSFS=n Greg Kroah-Hartman

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=11716690662679-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mstoilov@odesys.com \
    --subject='Re: [PATCH 04/10] kobject: kobj->k_name verification fix' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).