Skip to contentSkip to conversation

drivers/cpufreq/powernv-cpufreq.c:1130 powernv_cpufreq_init() error: buffer overflow 'powernv_cpu_freq_attr' 2 <= 2

PATCH New Dan Carpenter 1 participant 1 message Jan 31, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 34/47 drivers/cpufreq/powernv-cpufreq.c:1130 powernv_cpufreq_init() error: buffer overflow 'powernv_cpu_freq_attr' 2 <= 2

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git cpufreq/core-attr
head:   e3129c51f8623ce847b0486105bc00cd45ca0250
commit: 8ff649df04cd3fb05febecb28114cb116f68dcad [34/47] cpufreq: powernv: Stop setting common freq attributes
config: powerpc64-randconfig-r073-20250130 (https://download.01.org/0day-ci/archive/20250131/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/cpufreq/powernv-cpufreq.c:1130 powernv_cpufreq_init() error: buffer overflow 'powernv_cpu_freq_attr' 2 <= 2

vim +/powernv_cpu_freq_attr +1130 drivers/cpufreq/powernv-cpufreq.c

b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1109  static int __init powernv_cpufreq_init(void)
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1110  {
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1111  	int rc = 0;
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1112  
6174bac8c7ff73 Vaidyanathan Srinivasan 2014-08-03  1113  	/* Don't probe on pseries (guest) platforms */
e4d54f71d29997 Stewart Smith           2015-12-09  1114  	if (!firmware_has_feature(FW_FEATURE_OPAL))
6174bac8c7ff73 Vaidyanathan Srinivasan 2014-08-03  1115  		return -ENODEV;
6174bac8c7ff73 Vaidyanathan Srinivasan 2014-08-03  1116  
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1117  	/* Discover pstates from device tree and init */
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1118  	rc = init_powernv_pstates();
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1119  	if (rc)
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1120  		goto out;
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1121  
053819e0bf8407 Shilpasri G Bhat        2015-07-16  1122  	/* Populate chip info */
053819e0bf8407 Shilpasri G Bhat        2015-07-16  1123  	rc = init_chip_info();
053819e0bf8407 Shilpasri G Bhat        2015-07-16  1124  	if (rc)
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1125  		goto out;
053819e0bf8407 Shilpasri G Bhat        2015-07-16  1126  
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1127  	if (powernv_pstate_info.wof_enabled)
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1128  		powernv_cpufreq_driver.boost_enabled = true;
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1129  	else
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03 @1130  		powernv_cpu_freq_attr[SCALING_BOOST_FREQS_ATTR_INDEX] = NULL;
                                                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

out of bounds. ;)

c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1131  
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1132  	rc = cpufreq_register_driver(&powernv_cpufreq_driver);
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1133  	if (rc) {
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1134  		pr_info("Failed to register the cpufreq driver (%d)\n", rc);
966c08de7c2c9b Oliver O'Halloran       2020-02-06  1135  		goto cleanup;
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1136  	}
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1137  
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1138  	if (powernv_pstate_info.wof_enabled)
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1139  		cpufreq_enable_boost_support();
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1140  
966c08de7c2c9b Oliver O'Halloran       2020-02-06  1141  	register_reboot_notifier(&powernv_cpufreq_reboot_nb);
966c08de7c2c9b Oliver O'Halloran       2020-02-06  1142  	opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
966c08de7c2c9b Oliver O'Halloran       2020-02-06  1143  
b12f7a2b01f7ad Shilpasri G Bhat        2017-01-03  1144  	return 0;
966c08de7c2c9b Oliver O'Halloran       2020-02-06  1145  cleanup:
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1146  	clean_chip_info();
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1147  out:
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1148  	pr_info("Platform driver disabled. System does not support PState control\n");
c5e29ea7ac1441 Shilpasri G Bhat        2016-02-26  1149  	return rc;
b3d627a5f2bf1a Vaidyanathan Srinivasan 2014-04-01  1150  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki