On Thu, Nov 14, 2024 at 9:01 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote: > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git bleeding-edge > head: d1bf954af846f66ac2ea07b2457b4a089a009c08 > commit: 498ea32432db6f2a0bce88fd521e529a58a370c4 [447/448] thermal: testing: Use DEFINE_FREE() and __free() to simplify code > config: x86_64-randconfig-161-20241113 (https://download.01.org/0day-ci/archive/20241114/202411140825.w4TfKdbS-lkp@xxxxxxxxx/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 <lkp@xxxxxxxxx> > | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > | Closes: https://lore.kernel.org/r/202411140825.w4TfKdbS-lkp@xxxxxxxxx/ > > New smatch warnings: > drivers/thermal/testing/zone.c:333 tt_zone_add_trip() error: uninitialized symbol 'tt_zone'. > drivers/thermal/testing/zone.c:333 tt_zone_add_trip() error: uninitialized symbol 'tt_zone'. > > Old smatch warnings: > drivers/thermal/testing/zone.c:188 tt_add_tz() error: uninitialized symbol 'tt_work'. > drivers/thermal/testing/zone.c:240 tt_del_tz() error: uninitialized symbol 'tt_work'. > drivers/thermal/testing/zone.c:335 tt_zone_add_trip() error: uninitialized symbol 'tt_trip'. > drivers/thermal/testing/zone.c:390 tt_zone_register_tz() error: uninitialized symbol 'trips'. > > vim +/tt_zone +333 drivers/thermal/testing/zone.c > > f6a034f2df426e Rafael J. Wysocki 2024-08-22 331 int tt_zone_add_trip(const char *arg) > f6a034f2df426e Rafael J. Wysocki 2024-08-22 332 { > 498ea32432db6f Rafael J. Wysocki 2024-11-10 @333 struct tt_thermal_zone *tt_zone __free(put_tt_zone); > > These __free() pointers need to be initialized to NULL otherwise it leads to an > uninitialized variable when we return before they're assigned. Good point. I've fixed this particular one in the tree and I'll send a patch to fix the other cases later today. Thanks! > f6a034f2df426e Rafael J. Wysocki 2024-08-22 334 struct tt_work *tt_work __free(kfree); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 335 struct tt_trip *tt_trip __free(kfree); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 336 int id; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 337 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 338 tt_work = kzalloc(sizeof(*tt_work), GFP_KERNEL); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 339 if (!tt_work) > f6a034f2df426e Rafael J. Wysocki 2024-08-22 340 return -ENOMEM; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 341 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 342 tt_trip = kzalloc(sizeof(*tt_trip), GFP_KERNEL); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 343 if (!tt_trip) > f6a034f2df426e Rafael J. Wysocki 2024-08-22 344 return -ENOMEM; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 345 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 346 tt_zone = tt_get_tt_zone(arg); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 347 if (IS_ERR(tt_zone)) > f6a034f2df426e Rafael J. Wysocki 2024-08-22 348 return PTR_ERR(tt_zone); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 349 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 350 id = ida_alloc(&tt_zone->ida, GFP_KERNEL); > 498ea32432db6f Rafael J. Wysocki 2024-11-10 351 if (id < 0) > f6a034f2df426e Rafael J. Wysocki 2024-08-22 352 return id; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 353 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 354 tt_trip->trip.type = THERMAL_TRIP_ACTIVE; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 355 tt_trip->trip.temperature = THERMAL_TEMP_INVALID; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 356 tt_trip->trip.flags = THERMAL_TRIP_FLAG_RW; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 357 tt_trip->id = id; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 358 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 359 guard(tt_zone)(tt_zone); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 360 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 361 list_add_tail(&tt_trip->list_node, &tt_zone->trips); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 362 tt_zone->num_trips++; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 363 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 364 INIT_WORK(&tt_work->work, tt_zone_add_trip_work_fn); > 498ea32432db6f Rafael J. Wysocki 2024-11-10 365 tt_work->tt_zone = no_free_ptr(tt_zone); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 366 tt_work->tt_trip = no_free_ptr(tt_trip); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 367 schedule_work(&(no_free_ptr(tt_work)->work)); > f6a034f2df426e Rafael J. Wysocki 2024-08-22 368 > f6a034f2df426e Rafael J. Wysocki 2024-08-22 369 return 0; > f6a034f2df426e Rafael J. Wysocki 2024-08-22 370 } > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki > >