perf/x86/intel: Fix static checker warning in lbr enable
authorKan Liang <kan.liang@intel.com>
Mon, 14 Sep 2015 14:14:07 +0000 (10:14 -0400)
committerIngo Molnar <mingo@kernel.org>
Fri, 18 Sep 2015 07:24:57 +0000 (09:24 +0200)
Commit deb27519bf1f ("perf/x86/intel: Fix LBR callstack issue caused
by FREEZE_LBRS_ON_PMI") leads to the following Smatch complaint:

   warn: variable dereferenced before check 'cpuc->lbr_sel' (see line 154)

Fix the warning.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kan Liang <kan.liang@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: deb27519bf1f ("perf/x86/intel: Fix LBR callstack issue caused by FREEZE_LBRS_ON_PMI")
Link: http://lkml.kernel.org/r/1442240047-48149-1-git-send-email-kan.liang@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/perf_event_intel_lbr.c

index a1d07c71d3b6179a989efcdd78be914400f69442..ad0b8b0490a0e7691a1a84e89e3442261b78fc9b 100644 (file)
@@ -151,8 +151,9 @@ static void __intel_pmu_lbr_enable(bool pmi)
         * No need to reprogram LBR_SELECT in a PMI, as it
         * did not change.
         */
-       lbr_select = cpuc->lbr_sel->config;
-       if (cpuc->lbr_sel && !pmi)
+       if (cpuc->lbr_sel)
+               lbr_select = cpuc->lbr_sel->config;
+       if (!pmi)
                wrmsrl(MSR_LBR_SELECT, lbr_select);
 
        rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);