mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: akpm@osdl.org, mochel@digitalimplant.org, linux-kernel@vger.kernel.org
Subject: [patch] broken kref-counting in find functions.
Date: Thu, 24 Nov 2005 15:51:32 +0100	[thread overview]
Message-ID: <20051124145132.GA5057@skybase.boeblingen.de.ibm.com> (raw)

From: Frank Pavlic <pavlic@de.ibm.com>

[patch] broken kref-counting in find functions.

The klist reference counting in the find functions that use
klist_iter_init_node is broken. If the function (for example
driver_find_device) is called with a NULL start object then
everything is fine, the first call to next_device()/klist_next
increases the ref-count of the first node on the list and does
nothing for the start object which is NULL.
If they are called with a valid start object then klist_next
will decrement the ref-count for the start object but nobody
has incremented it. Logical place to fix this would be
klist_iter_init_node because the function puts a reference
of the object into the klist_iter struct.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Frank Pavlic <pavlic@de.ibm.com>

---

diff -urpN linux-2.6/lib/klist.c linux-2.6-patched/lib/klist.c
--- linux-2.6/lib/klist.c	2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/lib/klist.c	2005-11-23 18:33:34.000000000 +0100
@@ -199,6 +199,8 @@ void klist_iter_init_node(struct klist *
 	i->i_klist = k;
 	i->i_head = &k->k_list;
 	i->i_cur = n;
+	if (n)
+		kref_get(&n->n_ref);
 }
 
 EXPORT_SYMBOL_GPL(klist_iter_init_node);

                 reply	other threads:[~2005-11-24 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20051124145132.GA5057@skybase.boeblingen.de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mochel@digitalimplant.org \
    /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

all inboxes | Powered by JetHome®