tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 82e4255305c554b0bb18b7ccf2db86041b4c8b6e commit: c6ed48ef52599098498a8442fd60bea5bd8cd309 [9580/10049] power: supply: add ChromeOS EC based charge control driver config: x86_64-randconfig-012-20240702 (https://download.01.org/0day-ci/archive/20240702/202407022251.MmrQxLGJ-lkp@xxxxxxxxx/config) compiler: gcc-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240702/202407022251.MmrQxLGJ-lkp@xxxxxxxxx/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@xxxxxxxxx> | Closes: https://lore.kernel.org/oe-kbuild-all/202407022251.MmrQxLGJ-lkp@xxxxxxxxx/ All warnings (new ones prefixed by >>): drivers/power/supply/cros_charge-control.c: In function 'cros_chctl_probe': >> drivers/power/supply/cros_charge-control.c:297:18: warning: array subscript 3 is above array bounds of 'struct attribute *[3]' [-Warray-bounds] priv->attributes[_CROS_CHCTL_ATTR_COUNT] = NULL; ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ vim +297 drivers/power/supply/cros_charge-control.c 258 259 static int cros_chctl_probe(struct platform_device *pdev) 260 { 261 struct device *dev = &pdev->dev; 262 struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent); 263 struct cros_ec_device *cros_ec = ec_dev->ec_dev; 264 struct cros_chctl_priv *priv; 265 size_t i; 266 int ret; 267 268 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 269 if (!priv) 270 return -ENOMEM; 271 272 ret = cros_ec_get_cmd_versions(cros_ec, EC_CMD_CHARGE_CONTROL); 273 if (ret < 0) 274 return ret; 275 else if (ret & EC_VER_MASK(3)) 276 priv->cmd_version = 3; 277 else if (ret & EC_VER_MASK(2)) 278 priv->cmd_version = 2; 279 else if (ret & EC_VER_MASK(1)) 280 priv->cmd_version = 1; 281 else 282 return -ENODEV; 283 284 dev_dbg(dev, "Command version: %u\n", (unsigned int)priv->cmd_version); 285 286 priv->cros_ec = cros_ec; 287 priv->device_attrs[CROS_CHCTL_ATTR_START_THRESHOLD] = 288 (struct device_attribute)__ATTR_RW(charge_control_start_threshold); 289 priv->device_attrs[CROS_CHCTL_ATTR_END_THRESHOLD] = 290 (struct device_attribute)__ATTR_RW(charge_control_end_threshold); 291 priv->device_attrs[CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR] = 292 (struct device_attribute)__ATTR_RW(charge_behaviour); 293 for (i = 0; i < _CROS_CHCTL_ATTR_COUNT; i++) { 294 sysfs_attr_init(&priv->device_attrs[i].attr); 295 priv->attributes[i] = &priv->device_attrs[i].attr; 296 } > 297 priv->attributes[_CROS_CHCTL_ATTR_COUNT] = NULL; 298 priv->group.is_visible = cros_chtl_attr_is_visible; 299 priv->group.attrs = priv->attributes; 300 301 priv->battery_hook.name = dev_name(dev); 302 priv->battery_hook.add_battery = cros_chctl_add_battery; 303 priv->battery_hook.remove_battery = cros_chctl_remove_battery; 304 305 priv->current_behaviour = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; 306 priv->current_start_threshold = 0; 307 priv->current_end_threshold = 100; 308 309 /* Bring EC into well-known state */ 310 ret = cros_chctl_configure_ec(priv); 311 if (ret < 0) 312 return ret; 313 314 return devm_battery_hook_register(dev, &priv->battery_hook); 315 } 316 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki