public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Stephen Boyd <sboyd@codeaurora.org>,
	Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel: kallsyms: parameters checking, for EXPORT_SYMBOL_GPL functions
Date: Tue, 09 Apr 2013 14:00:58 +0800	[thread overview]
Message-ID: <5163AE9A.8060505@asianux.com> (raw)


  for EXPORT_SYMBOL_GPL functions, necessary to check their parameters.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/kallsyms.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 2169fee..4ba57a9 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -175,6 +175,9 @@ unsigned long kallsyms_lookup_name(const char *name)
 	unsigned long i;
 	unsigned int off;
 
+	if (!name || !name[0])
+		return 0;
+
 	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
 		off = kallsyms_expand_symbol(off, namebuf);
 
@@ -194,6 +197,9 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
 	unsigned int off;
 	int ret;
 
+	if (!fn)
+		return -EINVAL;
+
 	for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
 		off = kallsyms_expand_symbol(off, namebuf);
 		ret = fn(data, namebuf, NULL, kallsyms_addresses[i]);
@@ -382,6 +388,9 @@ static int __sprint_symbol(char *buffer, unsigned long address,
  */
 int sprint_symbol(char *buffer, unsigned long address)
 {
+	if (!buffer)
+		return 0;
+
 	return __sprint_symbol(buffer, address, 0, 1);
 }
 EXPORT_SYMBOL_GPL(sprint_symbol);
@@ -399,6 +408,9 @@ EXPORT_SYMBOL_GPL(sprint_symbol);
  */
 int sprint_symbol_no_offset(char *buffer, unsigned long address)
 {
+	if (!buffer)
+		return 0;
+
 	return __sprint_symbol(buffer, address, 0, 0);
 }
 EXPORT_SYMBOL_GPL(sprint_symbol_no_offset);
-- 
1.7.7.6

             reply	other threads:[~2013-04-09  6:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09  6:00 Chen Gang [this message]
2013-04-10  6:57 ` [PATCH] kernel: kallsyms: parameters checking, for EXPORT_SYMBOL_GPL functions Rusty Russell
2013-04-10 10:56   ` Chen Gang
2013-04-11  2:52     ` Rusty Russell
2013-04-11  4:27       ` Chen Gang

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=5163AE9A.8060505@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sboyd@codeaurora.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