[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202207101807.UYiCXGqy-lkp@intel.com>
Date: Sun, 10 Jul 2022 19:02:22 +0800
From: kernel test robot <lkp@...el.com>
To: Cristian Marussi <cristian.marussi@....com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
Sudeep Holla <sudeep.holla@....com>
Subject: [sudeep-holla:for-next/scmi 22/22]
drivers/powercap/arm_scmi_powercap.c:429 scmi_powercap_probe() warn:
unsigned 'pr->num_zones' is never less than zero.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux.git for-next/scmi
head: 31afdd34f2b9e1f33018baa4f279e2b2a91f5afa
commit: 31afdd34f2b9e1f33018baa4f279e2b2a91f5afa [22/22] powercap: arm_scmi: Add SCMI powercap based driver
config: microblaze-randconfig-m031-20220706 (https://download.01.org/0day-ci/archive/20220710/202207101807.UYiCXGqy-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
smatch warnings:
drivers/powercap/arm_scmi_powercap.c:429 scmi_powercap_probe() warn: unsigned 'pr->num_zones' is never less than zero.
drivers/powercap/arm_scmi_powercap.c:494 scmi_powercap_probe() error: uninitialized symbol 'ret'.
vim +429 drivers/powercap/arm_scmi_powercap.c
406
407 static int scmi_powercap_probe(struct scmi_device *sdev)
408 {
409 int ret, i;
410 struct scmi_powercap_root *pr;
411 struct scmi_powercap_zone *spz;
412 struct scmi_protocol_handle *ph;
413 struct device *dev = &sdev->dev;
414 const struct scmi_handle *handle = sdev->handle;
415
416 if (!handle)
417 return -ENODEV;
418
419 powercap_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_POWERCAP,
420 &ph);
421 if (IS_ERR(powercap_ops))
422 return PTR_ERR(powercap_ops);
423
424 pr = devm_kzalloc(dev, sizeof(*pr), GFP_KERNEL);
425 if (!pr)
426 return -ENOMEM;
427
428 pr->num_zones = powercap_ops->num_domains_get(ph);
> 429 if (pr->num_zones < 0) {
430 dev_err(dev, "number of powercap domains not found\n");
431 return pr->num_zones;
432 }
433
434 pr->spzones = devm_kcalloc(dev, pr->num_zones,
435 sizeof(*pr->spzones), GFP_KERNEL);
436 if (!pr->spzones)
437 return -ENOMEM;
438
439 /* Allocate for worst possible scenario of maximum tree height. */
440 pr->registered_zones = devm_kcalloc(dev, pr->num_zones,
441 sizeof(*pr->registered_zones),
442 GFP_KERNEL);
443 if (!pr->registered_zones)
444 return -ENOMEM;
445
446 for (i = 0, spz = pr->spzones; i < pr->num_zones; i++, spz++) {
447 /*
448 * Powercap domains are validate by the protocol layer, i.e.
449 * when only non-NULL domains are returned here, whose
450 * parent_id is assured to point to another valid domain.
451 */
452 spz->info = powercap_ops->info_get(ph, i);
453
454 spz->dev = dev;
455 spz->ph = ph;
456 spz->spzones = pr->spzones;
457 INIT_LIST_HEAD(&spz->node);
458 INIT_LIST_HEAD(&pr->registered_zones[i]);
459
460 /*
461 * Forcibly skip powercap domains using an abstract scale.
462 * Note that only leaves domains can be skipped, so this could
463 * lead later to a global failure.
464 */
465 if (!spz->info->powercap_scale_uw &&
466 !spz->info->powercap_scale_mw) {
467 dev_warn(dev,
468 "Abstract power scale not supported. Skip %s.\n",
469 spz->info->name);
470 spz->info = NULL;
471 continue;
472 }
473 }
474
475 /*
476 * Scan array of retrieved SCMI powercap domains and register them
477 * recursively starting from the root domains.
478 */
479 for (i = 0, spz = pr->spzones; i < pr->num_zones; i++, spz++) {
480 ret = scmi_powercap_register_zone(pr, spz);
481 if (ret) {
482 dev_err(dev,
483 "Failed to register powercap zone %s - ret:%d\n",
484 spz->info->name, ret);
485 scmi_powercap_unregister_all_zones(pr);
486 return ret;
487 }
488 }
489
490 dev_set_drvdata(dev, pr);
491
492 dev_info(dev, "Registered %d SCMI Powercap domains !\n", pr->num_zones);
493
> 494 return ret;
495 }
496
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists