[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202311100157.2Kn3gHLg-lkp@intel.com>
Date: Fri, 10 Nov 2023 01:27:40 +0800
From: kernel test robot <lkp@...el.com>
To: Christophe Leroy <christophe.leroy@....fr>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Michael Ellerman <mpe@...erman.id.au>
Subject: drivers/power/supply/pmu_battery.c:171:50: warning: '%d' directive
writing between 1 and 11 bytes into a region of size 4
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6bc986ab839c844e78a2333a02e55f02c9e57935
commit: 2edb16efc899f9c232e2d880930b855e4cf55df4 powerpc/32: Add KASAN support
date: 4 years, 6 months ago
config: powerpc-randconfig-r031-20211015 (https://download.01.org/0day-ci/archive/20231110/202311100157.2Kn3gHLg-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 12.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231110/202311100157.2Kn3gHLg-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311100157.2Kn3gHLg-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/power/supply/pmu_battery.c: In function 'pmu_bat_init':
>> drivers/power/supply/pmu_battery.c:171:50: warning: '%d' directive writing between 1 and 11 bytes into a region of size 4 [-Wformat-overflow=]
171 | sprintf(pbat->name, "PMU_battery_%d", i);
| ^~
drivers/power/supply/pmu_battery.c:171:37: note: directive argument in the range [-2147483643, 2147483646]
171 | sprintf(pbat->name, "PMU_battery_%d", i);
| ^~~~~~~~~~~~~~~~
drivers/power/supply/pmu_battery.c:171:17: note: 'sprintf' output between 14 and 24 bytes into a destination of size 16
171 | sprintf(pbat->name, "PMU_battery_%d", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +171 drivers/power/supply/pmu_battery.c
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 145
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 146 static int __init pmu_bat_init(void)
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 147 {
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 148 int ret = 0;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 149 int i;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 150
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 151 bat_pdev = platform_device_register_simple("pmu-battery",
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 152 0, NULL, 0);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 153 if (IS_ERR(bat_pdev)) {
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 154 ret = PTR_ERR(bat_pdev);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 155 goto pdev_register_failed;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 156 }
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 157
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 158 pmu_ac = power_supply_register(&bat_pdev->dev, &pmu_ac_desc, NULL);
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 159 if (IS_ERR(pmu_ac)) {
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 160 ret = PTR_ERR(pmu_ac);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 161 goto ac_register_failed;
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 162 }
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 163
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 164 for (i = 0; i < pmu_battery_count; i++) {
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 165 struct power_supply_config psy_cfg = {};
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 166 struct pmu_battery_dev *pbat = kzalloc(sizeof(*pbat),
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 167 GFP_KERNEL);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 168 if (!pbat)
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 169 break;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 170
35bf559145b633 drivers/power/pmu_battery.c Christian Kujau 2008-05-02 @171 sprintf(pbat->name, "PMU_battery_%d", i);
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 172 pbat->bat_desc.name = pbat->name;
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 173 pbat->bat_desc.properties = pmu_bat_props;
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 174 pbat->bat_desc.num_properties = ARRAY_SIZE(pmu_bat_props);
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 175 pbat->bat_desc.get_property = pmu_bat_get_property;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 176 pbat->pbi = &pmu_batteries[i];
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 177 psy_cfg.drv_data = pbat;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 178
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 179 pbat->bat = power_supply_register(&bat_pdev->dev,
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 180 &pbat->bat_desc,
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 181 &psy_cfg);
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 182 if (IS_ERR(pbat->bat)) {
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 183 ret = PTR_ERR(pbat->bat);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 184 kfree(pbat);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 185 goto battery_register_failed;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 186 }
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 187 pbats[i] = pbat;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 188 }
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 189
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 190 goto success;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 191
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 192 battery_register_failed:
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 193 while (i--) {
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 194 if (!pbats[i])
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 195 continue;
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 196 power_supply_unregister(pbats[i]->bat);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 197 kfree(pbats[i]);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 198 }
297d716f6260cc drivers/power/pmu_battery.c Krzysztof Kozlowski 2015-03-12 199 power_supply_unregister(pmu_ac);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 200 ac_register_failed:
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 201 platform_device_unregister(bat_pdev);
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 202 pdev_register_failed:
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 203 success:
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 204 return ret;
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 205 }
efea58e397dec8 drivers/power/pmu_battery.c David Woodhouse 2007-05-04 206
:::::: The code at line 171 was first introduced by commit
:::::: 35bf559145b6332f5465c15a4e5cd7a363985382 PMU battery: filenames in sysfs with spaces
:::::: TO: Christian Kujau <lists@...dbynature.de>
:::::: CC: Anton Vorontsov <cbouatmailru@...il.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists