All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: arch/x86/kernel/kvmclock.c:269 kvmclock_setup_percpu() error: testing array offset 'cpu' after use.
Date: Sun, 3 Dec 2023 23:48:42 +0800	[thread overview]
Message-ID: <202312032306.PrSrLRqa-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Thomas Gleixner <tglx@linutronix.de>
CC: Pavel Tatashin <pasha.tatashin@oracle.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   33cc938e65a98f1d29d0a18403dbbee050dcad9a
commit: 95a3d4454bb1cf5bfd666c27fdd2dc188e17c14d x86/kvmclock: Switch kvmclock data to a PER_CPU variable
date:   5 years ago
:::::: branch date: 5 hours ago
:::::: commit date: 5 years ago
config: x86_64-randconfig-x006-20230817 (https://download.01.org/0day-ci/archive/20231203/202312032306.PrSrLRqa-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231203/202312032306.PrSrLRqa-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202312032306.PrSrLRqa-lkp@intel.com/

smatch warnings:
arch/x86/kernel/kvmclock.c:269 kvmclock_setup_percpu() error: testing array offset 'cpu' after use.

vim +/cpu +269 arch/x86/kernel/kvmclock.c

e499a9b6dc488a Thomas Gleixner 2018-07-19  255  
95a3d4454bb1cf Thomas Gleixner 2018-07-19  256  static int kvmclock_setup_percpu(unsigned int cpu)
95a3d4454bb1cf Thomas Gleixner 2018-07-19  257  {
95a3d4454bb1cf Thomas Gleixner 2018-07-19  258  	struct pvclock_vsyscall_time_info *p = per_cpu(hv_clock_per_cpu, cpu);
95a3d4454bb1cf Thomas Gleixner 2018-07-19  259  
95a3d4454bb1cf Thomas Gleixner 2018-07-19  260  	/*
95a3d4454bb1cf Thomas Gleixner 2018-07-19  261  	 * The per cpu area setup replicates CPU0 data to all cpu
95a3d4454bb1cf Thomas Gleixner 2018-07-19  262  	 * pointers. So carefully check. CPU0 has been set up in init
95a3d4454bb1cf Thomas Gleixner 2018-07-19  263  	 * already.
95a3d4454bb1cf Thomas Gleixner 2018-07-19  264  	 */
95a3d4454bb1cf Thomas Gleixner 2018-07-19  265  	if (!cpu || (p && p != per_cpu(hv_clock_per_cpu, 0)))
95a3d4454bb1cf Thomas Gleixner 2018-07-19  266  		return 0;
95a3d4454bb1cf Thomas Gleixner 2018-07-19  267  
95a3d4454bb1cf Thomas Gleixner 2018-07-19  268  	/* Use the static page for the first CPUs, allocate otherwise */
95a3d4454bb1cf Thomas Gleixner 2018-07-19 @269  	if (cpu < HVC_BOOT_ARRAY_SIZE)
95a3d4454bb1cf Thomas Gleixner 2018-07-19  270  		p = &hv_clock_boot[cpu];
95a3d4454bb1cf Thomas Gleixner 2018-07-19  271  	else
95a3d4454bb1cf Thomas Gleixner 2018-07-19  272  		p = kzalloc(sizeof(*p), GFP_KERNEL);
95a3d4454bb1cf Thomas Gleixner 2018-07-19  273  
95a3d4454bb1cf Thomas Gleixner 2018-07-19  274  	per_cpu(hv_clock_per_cpu, cpu) = p;
95a3d4454bb1cf Thomas Gleixner 2018-07-19  275  	return p ? 0 : -ENOMEM;
95a3d4454bb1cf Thomas Gleixner 2018-07-19  276  }
95a3d4454bb1cf Thomas Gleixner 2018-07-19  277  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2023-12-03 15:48 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=202312032306.PrSrLRqa-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.