lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202207251957.44kuib07-lkp@intel.com>
Date:   Mon, 25 Jul 2022 19:50:34 +0800
From:   kernel test robot <lkp@...el.com>
To:     Kan Liang <kan.liang@...ux.intel.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Andi Kleen <ak@...ux.intel.com>
Subject: arch/x86/events/core.c:1869:25: warning: Local variable 'pmu'
 shadows outer variable [shadowVariable]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e0dccc3b76fb35bb257b4118367a883073d7390e
commit: a9c81ccdf52dd73a20178c40bca34cf52991fdea perf/x86: Add structures for the attributes of Hybrid PMUs
date:   1 year, 3 months ago
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout a9c81ccdf52dd73a20178c40bca34cf52991fdea
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>

cppcheck warnings: (new ones prefixed by >>)
                                         ^
   arch/x86/events/core.c:766:20: note: Using pointer that is a temporary.
    if (WARN_ON_ONCE(!cpuc->pmu))
                      ^
>> arch/x86/events/core.c:1869:25: warning: Local variable 'pmu' shadows outer variable [shadowVariable]
    struct x86_hybrid_pmu *pmu;
                           ^
   arch/x86/events/core.c:48:19: note: Shadowed declaration
   static struct pmu pmu;
                     ^
   arch/x86/events/core.c:1869:25: note: Shadow variable
    struct x86_hybrid_pmu *pmu;
                           ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

                                         ^
   arch/x86/events/core.c:766:20: note: Using pointer that is a temporary.
    if (WARN_ON_ONCE(!cpuc->pmu))
                      ^
   arch/x86/events/core.c:769:9: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
    return cpuc->pmu;
           ^
   arch/x86/events/core.c:760:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:766:18: note: Assuming condition is false
    if (WARN_ON_ONCE(!cpuc->pmu))
                    ^
   arch/x86/events/core.c:760:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:769:9: note: Using pointer that is a temporary.
    return cpuc->pmu;
           ^
   arch/x86/events/core.c:1561:56: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
    pr_info("CPU#%d: active:     %016llxn", cpu, *(u64 *)cpuc->active_mask);
                                                          ^
   arch/x86/events/core.c:1529:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:1536:6: note: Assuming condition is false
    if (!num_counters)
        ^
   arch/x86/events/core.c:1529:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:1561:56: note: Using pointer that is a temporary.
    pr_info("CPU#%d: active:     %016llxn", cpu, *(u64 *)cpuc->active_mask);
                                                          ^
   arch/x86/events/core.c:1577:35: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
     if (fixed_counter_disabled(idx, cpuc->pmu))
                                     ^
   arch/x86/events/core.c:1529:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:1536:6: note: Assuming condition is false
    if (!num_counters)
        ^
   arch/x86/events/core.c:1529:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:1577:35: note: Using pointer that is a temporary.
     if (fixed_counter_disabled(idx, cpuc->pmu))
                                     ^
   arch/x86/events/core.c:1760:3: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
     cpuc->kfree_on_online[i] = NULL;
     ^
   arch/x86/events/core.c:1756:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:1756:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:1760:3: note: Using pointer that is a temporary.
     cpuc->kfree_on_online[i] = NULL;
     ^
   arch/x86/events/core.c:1779:9: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
     kfree(cpuc->kfree_on_online[i]);
           ^
   arch/x86/events/core.c:1775:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:1775:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:1779:9: note: Using pointer that is a temporary.
     kfree(cpuc->kfree_on_online[i]);
           ^
   arch/x86/events/core.c:1780:3: warning: Using pointer that is a temporary. [danglingTemporaryLifetime]
     cpuc->kfree_on_online[i] = NULL;
     ^
   arch/x86/events/core.c:1775:31: note: Address of variable taken here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                 ^
   arch/x86/events/core.c:1775:39: note: Temporary created here.
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
                                         ^
   arch/x86/events/core.c:1780:3: note: Using pointer that is a temporary.
     cpuc->kfree_on_online[i] = NULL;
     ^
   arch/x86/events/core.c:2113:3: warning: Same expression on both sides of '-'. [duplicateExpression]
     __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
     ^
   arch/x86/events/core.c:2163:26: warning: Local variable 'hybrid_pmu' shadows outer function [shadowFunction]
     struct x86_hybrid_pmu *hybrid_pmu;
                            ^
   arch/x86/events/perf_event.h:660:47: note: Shadowed declaration
   static __always_inline struct x86_hybrid_pmu *hybrid_pmu(struct pmu *pmu)
                                                 ^
   arch/x86/events/core.c:2163:26: note: Shadow variable
     struct x86_hybrid_pmu *hybrid_pmu;
                            ^

vim +/pmu +1869 arch/x86/events/core.c

  1862	
  1863	ssize_t events_hybrid_sysfs_show(struct device *dev,
  1864					 struct device_attribute *attr,
  1865					 char *page)
  1866	{
  1867		struct perf_pmu_events_hybrid_attr *pmu_attr =
  1868			container_of(attr, struct perf_pmu_events_hybrid_attr, attr);
> 1869		struct x86_hybrid_pmu *pmu;
  1870		const char *str, *next_str;
  1871		int i;
  1872	
  1873		if (hweight64(pmu_attr->pmu_type) == 1)
  1874			return sprintf(page, "%s", pmu_attr->event_str);
  1875	
  1876		/*
  1877		 * Hybrid PMUs may support the same event name, but with different
  1878		 * event encoding, e.g., the mem-loads event on an Atom PMU has
  1879		 * different event encoding from a Core PMU.
  1880		 *
  1881		 * The event_str includes all event encodings. Each event encoding
  1882		 * is divided by ";". The order of the event encodings must follow
  1883		 * the order of the hybrid PMU index.
  1884		 */
  1885		pmu = container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
  1886	
  1887		str = pmu_attr->event_str;
  1888		for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
  1889			if (!(x86_pmu.hybrid_pmu[i].cpu_type & pmu_attr->pmu_type))
  1890				continue;
  1891			if (x86_pmu.hybrid_pmu[i].cpu_type & pmu->cpu_type) {
  1892				next_str = strchr(str, ';');
  1893				if (next_str)
  1894					return snprintf(page, next_str - str + 1, "%s", str);
  1895				else
  1896					return sprintf(page, "%s", str);
  1897			}
  1898			str = strchr(str, ';');
  1899			str++;
  1900		}
  1901	
  1902		return 0;
  1903	}
  1904	EXPORT_SYMBOL_GPL(events_hybrid_sysfs_show);
  1905	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ