linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dominic Chen <d.c.ddcc@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: rusty@rustcorp.com.au
Subject: [PATCH 1/1] module: Fix dangling pointer after kfree()
Date: Mon, 14 Nov 2011 18:58:08 -0700	[thread overview]
Message-ID: <4EC1C730.2050000@gmail.com> (raw)

remove_notes_attrs() calls free_notes_attrs(), which in turn calls
kfree() on mod->notes_attrs, but fails to set this dangling pointer to
NULL. This differs from both module_param_sysfs_remove() and
remove_sect_attrs(), which set the pointers to NULL after calling kfree().

Signed-off-by: Dominic Chen <d.c.ddcc@gmail.com>
---
 kernel/module.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 178333c..9ca0923 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1380,8 +1380,10 @@ static void add_notes_attrs(struct module *mod,
const struct load_info *info)

 static void remove_notes_attrs(struct module *mod)
 {
-	if (mod->notes_attrs)
+	if (mod->notes_attrs) {
 		free_notes_attrs(mod->notes_attrs, mod->notes_attrs->notes);
+		mod->notes_attrs = NULL;
+	}
 }

 #else
-- 
1.7.5.4

                 reply	other threads:[~2011-11-15  1:58 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=4EC1C730.2050000@gmail.com \
    --to=d.c.ddcc@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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;
as well as URLs for NNTP newsgroup(s).