linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dinggnu@gmail.com (Cong Ding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: kernel/perf_event_cpu.c: fix error null pointer dereference check
Date: Mon, 14 Jan 2013 17:18:53 +0000	[thread overview]
Message-ID: <1358183933-29160-1-git-send-email-dinggnu@gmail.com> (raw)

the pointer cpu_pmu is used without null pointer dereference check, and is
checked after the using of it, so we move the null pointer check to before the
first use.

Signed-off-by: Cong Ding <dinggnu@gmail.com>
---
 arch/arm/kernel/perf_event_cpu.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
index efa5295..16aa979 100644
--- a/arch/arm/kernel/perf_event_cpu.c
+++ b/arch/arm/kernel/perf_event_cpu.c
@@ -142,13 +142,15 @@ static void cpu_pmu_init(struct arm_pmu *cpu_pmu)
 		raw_spin_lock_init(&events->pmu_lock);
 	}
 
-	cpu_pmu->get_hw_events	= cpu_pmu_get_cpu_events;
-	cpu_pmu->request_irq	= cpu_pmu_request_irq;
-	cpu_pmu->free_irq	= cpu_pmu_free_irq;
+	if (cpu_pmu) {
+		cpu_pmu->get_hw_events	= cpu_pmu_get_cpu_events;
+		cpu_pmu->request_irq	= cpu_pmu_request_irq;
+		cpu_pmu->free_irq	= cpu_pmu_free_irq;
 
-	/* Ensure the PMU has sane values out of reset. */
-	if (cpu_pmu && cpu_pmu->reset)
-		on_each_cpu(cpu_pmu->reset, cpu_pmu, 1);
+		/* Ensure the PMU has sane values out of reset. */
+		if (cpu_pmu->reset)
+			on_each_cpu(cpu_pmu->reset, cpu_pmu, 1);
+	}
 }
 
 /*
-- 
1.7.9.5

             reply	other threads:[~2013-01-14 17:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 17:18 Cong Ding [this message]
2013-01-14 17:23 ` [PATCH] arm: kernel/perf_event_cpu.c: fix error null pointer dereference check Russell King - ARM Linux
2013-01-14 17:38   ` Cong Ding
2013-01-14 17:40     ` Will Deacon
2013-01-14 17:40 ` [PATCH v2] arm: kernel/perf_event_cpu.c: remove unnecessary " Cong Ding

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=1358183933-29160-1-git-send-email-dinggnu@gmail.com \
    --to=dinggnu@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).