drivers/gpu/drm/panthor/panthor_sched.c:2024:15-20: ERROR: invalid reference to the index variable of the iterator on line 1997 (fwd)

From: Julia Lawall
Date: Mon Sep 30 2024 - 11:45:25 EST


The use of group on line 2024 does not look right to me. It's not
pointing to a meaningful value at this point.

julia

---------- Forwarded message ----------
Date: Mon, 30 Sep 2024 23:39:48 +0800
From: kernel test robot <lkp@xxxxxxxxx>
To: oe-kbuild@xxxxxxxxxxxxxxx
Cc: lkp@xxxxxxxxx, Julia Lawall <julia.lawall@xxxxxxxx>
Subject: drivers/gpu/drm/panthor/panthor_sched.c:2024:15-20: ERROR: invalid
reference to the index variable of the iterator on line 1997

BCC: lkp@xxxxxxxxx
CC: oe-kbuild-all@xxxxxxxxxxxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
TO: Boris Brezillon <bbrezillon@xxxxxxxxxx>
CC: Steven Price <steven.price@xxxxxxx>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9852d85ec9d492ebef56dc5f229416c925758edc
commit: d72f049087d4f973f6332b599c92177e718107de drm/panthor: Allow driver compilation
date: 7 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 7 months ago
config: sparc-randconfig-r064-20240930 (https://download.01.org/0day-ci/archive/20240930/202409302306.UDikqa03-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 14.1.0

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: Julia Lawall <julia.lawall@xxxxxxxx>
| Closes: https://lore.kernel.org/r/202409302306.UDikqa03-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/panthor/panthor_sched.c:2024:15-20: ERROR: invalid reference to the index variable of the iterator on line 1997
drivers/gpu/drm/panthor/panthor_sched.c:2024:15-20: ERROR: invalid reference to the index variable of the iterator on line 2027

vim +2024 drivers/gpu/drm/panthor/panthor_sched.c

de85488138247d Boris Brezillon 2024-02-29 1988
de85488138247d Boris Brezillon 2024-02-29 1989 static void
de85488138247d Boris Brezillon 2024-02-29 1990 tick_ctx_cleanup(struct panthor_scheduler *sched,
de85488138247d Boris Brezillon 2024-02-29 1991 struct panthor_sched_tick_ctx *ctx)
de85488138247d Boris Brezillon 2024-02-29 1992 {
de85488138247d Boris Brezillon 2024-02-29 1993 struct panthor_group *group, *tmp;
de85488138247d Boris Brezillon 2024-02-29 1994 u32 i;
de85488138247d Boris Brezillon 2024-02-29 1995
de85488138247d Boris Brezillon 2024-02-29 1996 for (i = 0; i < ARRAY_SIZE(ctx->old_groups); i++) {
de85488138247d Boris Brezillon 2024-02-29 @1997 list_for_each_entry_safe(group, tmp, &ctx->old_groups[i], run_node) {
de85488138247d Boris Brezillon 2024-02-29 1998 /* If everything went fine, we should only have groups
de85488138247d Boris Brezillon 2024-02-29 1999 * to be terminated in the old_groups lists.
de85488138247d Boris Brezillon 2024-02-29 2000 */
de85488138247d Boris Brezillon 2024-02-29 2001 drm_WARN_ON(&group->ptdev->base, !ctx->csg_upd_failed_mask &&
de85488138247d Boris Brezillon 2024-02-29 2002 group_can_run(group));
de85488138247d Boris Brezillon 2024-02-29 2003
de85488138247d Boris Brezillon 2024-02-29 2004 if (!group_can_run(group)) {
de85488138247d Boris Brezillon 2024-02-29 2005 list_del_init(&group->run_node);
de85488138247d Boris Brezillon 2024-02-29 2006 list_del_init(&group->wait_node);
de85488138247d Boris Brezillon 2024-02-29 2007 group_queue_work(group, term);
de85488138247d Boris Brezillon 2024-02-29 2008 } else if (group->csg_id >= 0) {
de85488138247d Boris Brezillon 2024-02-29 2009 list_del_init(&group->run_node);
de85488138247d Boris Brezillon 2024-02-29 2010 } else {
de85488138247d Boris Brezillon 2024-02-29 2011 list_move(&group->run_node,
de85488138247d Boris Brezillon 2024-02-29 2012 group_is_idle(group) ?
de85488138247d Boris Brezillon 2024-02-29 2013 &sched->groups.idle[group->priority] :
de85488138247d Boris Brezillon 2024-02-29 2014 &sched->groups.runnable[group->priority]);
de85488138247d Boris Brezillon 2024-02-29 2015 }
de85488138247d Boris Brezillon 2024-02-29 2016 group_put(group);
de85488138247d Boris Brezillon 2024-02-29 2017 }
de85488138247d Boris Brezillon 2024-02-29 2018 }
de85488138247d Boris Brezillon 2024-02-29 2019
de85488138247d Boris Brezillon 2024-02-29 2020 for (i = 0; i < ARRAY_SIZE(ctx->groups); i++) {
de85488138247d Boris Brezillon 2024-02-29 2021 /* If everything went fine, the groups to schedule lists should
de85488138247d Boris Brezillon 2024-02-29 2022 * be empty.
de85488138247d Boris Brezillon 2024-02-29 2023 */
de85488138247d Boris Brezillon 2024-02-29 @2024 drm_WARN_ON(&group->ptdev->base,
de85488138247d Boris Brezillon 2024-02-29 2025 !ctx->csg_upd_failed_mask && !list_empty(&ctx->groups[i]));
de85488138247d Boris Brezillon 2024-02-29 2026
de85488138247d Boris Brezillon 2024-02-29 2027 list_for_each_entry_safe(group, tmp, &ctx->groups[i], run_node) {
de85488138247d Boris Brezillon 2024-02-29 2028 if (group->csg_id >= 0) {
de85488138247d Boris Brezillon 2024-02-29 2029 list_del_init(&group->run_node);
de85488138247d Boris Brezillon 2024-02-29 2030 } else {
de85488138247d Boris Brezillon 2024-02-29 2031 list_move(&group->run_node,
de85488138247d Boris Brezillon 2024-02-29 2032 group_is_idle(group) ?
de85488138247d Boris Brezillon 2024-02-29 2033 &sched->groups.idle[group->priority] :
de85488138247d Boris Brezillon 2024-02-29 2034 &sched->groups.runnable[group->priority]);
de85488138247d Boris Brezillon 2024-02-29 2035 }
de85488138247d Boris Brezillon 2024-02-29 2036 group_put(group);
de85488138247d Boris Brezillon 2024-02-29 2037 }
de85488138247d Boris Brezillon 2024-02-29 2038 }
de85488138247d Boris Brezillon 2024-02-29 2039 }
de85488138247d Boris Brezillon 2024-02-29 2040

:::::: The code at line 2024 was first introduced by commit
:::::: de85488138247d034eb3241840424a54d660926b drm/panthor: Add the scheduler logical block

:::::: TO: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
:::::: CC: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki