Re: [PATCH v15 2/7] coresight: tmc: add create/clean functions for etr_buf_list

From: kernel test robot

Date: Tue Mar 17 2026 - 04:44:50 EST


Hi Jie,

kernel test robot noticed the following build warnings:

[auto build test WARNING on a0ae2a256046c0c5d3778d1a194ff2e171f16e5f]

url: https://github.com/intel-lab-lkp/linux/commits/Jie-Gan/coresight-core-refactor-ctcu_get_active_port-and-make-it-generic/20260315-052703
base: a0ae2a256046c0c5d3778d1a194ff2e171f16e5f
patch link: https://lore.kernel.org/r/20260313-enable-byte-cntr-for-ctcu-v15-2-1777f14ed319%40oss.qualcomm.com
patch subject: [PATCH v15 2/7] coresight: tmc: add create/clean functions for etr_buf_list
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20260317/202603171518.XQOgdjNN-lkp@xxxxxxxxx/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260317/202603171518.XQOgdjNN-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/202603171518.XQOgdjNN-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/hwtracing/coresight/coresight-tmc-etr.c:1979:50: warning: variable 'flags' is uninitialized when used here [-Wuninitialized]
1979 | raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
| ^~~~~
include/linux/spinlock.h:283:37: note: expanded from macro 'raw_spin_unlock_irqrestore'
283 | _raw_spin_unlock_irqrestore(lock, flags); \
| ^~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:1969:21: note: initialize the variable 'flags' to silence this warning
1969 | unsigned long flags;
| ^
| = 0
1 warning generated.


vim +/flags +1979 drivers/hwtracing/coresight/coresight-tmc-etr.c

1957
1958 /**
1959 * tmc_create_etr_buf_list - create a list to manage the etr_buf_node.
1960 * @drvdata: driver data of the TMC device.
1961 * @num_nodes: number of nodes want to create with the list.
1962 *
1963 * Return 0 upon success and return the error number if fail.
1964 */
1965 int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes)
1966 {
1967 struct etr_buf_node *new_node;
1968 struct etr_buf *sysfs_buf;
1969 unsigned long flags;
1970 int i = 0, ret = 0;
1971
1972 lockdep_assert_held(&drvdata->spinlock);
1973 /* We dont need a list if there is only one node */
1974 if (num_nodes < 2)
1975 return -EINVAL;
1976
1977 /* We expect that sysfs_buf in drvdata has already been allocated. */
1978 if (drvdata->sysfs_buf) {
> 1979 raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
1980 /* Directly insert the allocated sysfs_buf into the list first */
1981 new_node = kzalloc_obj(*new_node, GFP_KERNEL);
1982 if (IS_ERR(new_node))
1983 return PTR_ERR(new_node);
1984
1985 raw_spin_lock_irqsave(&drvdata->spinlock, flags);
1986 new_node->sysfs_buf = drvdata->sysfs_buf;
1987 new_node->is_free = false;
1988 list_add(&new_node->link, &drvdata->etr_buf_list);
1989 i++;
1990 }
1991
1992 raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
1993 while (i < num_nodes) {
1994 new_node = kzalloc_obj(*new_node, GFP_KERNEL);
1995 if (IS_ERR(new_node)) {
1996 ret = PTR_ERR(new_node);
1997 break;
1998 }
1999
2000 sysfs_buf = tmc_alloc_etr_buf(drvdata, drvdata->size, 0, cpu_to_node(0), NULL);
2001 if (IS_ERR(sysfs_buf)) {
2002 kfree(new_node);
2003 ret = PTR_ERR(sysfs_buf);
2004 break;
2005 }
2006
2007 /* We dont have a available sysfs_buf in drvdata, setup one */
2008 if (!drvdata->sysfs_buf) {
2009 drvdata->sysfs_buf = sysfs_buf;
2010 new_node->is_free = false;
2011 } else
2012 new_node->is_free = true;
2013
2014 new_node->sysfs_buf = sysfs_buf;
2015 list_add(&new_node->link, &drvdata->etr_buf_list);
2016 i++;
2017 }
2018
2019 /* Clean the list if there is an error */
2020 if (ret)
2021 tmc_clean_etr_buf_list(drvdata);
2022
2023 raw_spin_lock_irqsave(&drvdata->spinlock, flags);
2024
2025 return ret;
2026 }
2027 EXPORT_SYMBOL_GPL(tmc_create_etr_buf_list);
2028

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