Re: [PATCH] kobject: Refactor kobject_set_name_vargs()

From: kernel test robot
Date: Fri May 06 2022 - 15:57:33 EST


Hi Jagdish,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on hnaz-mm/master linux/master linus/master v5.18-rc5 next-20220506]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Jagdish-Gediya/kobject-Refactor-kobject_set_name_vargs/20220506-213448
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git bc443c31def574e3bfaed50cb493b8305ad79435
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20220507/202205070311.4T8ZKSWq-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/4aac95bc8a052e61d5013a25a2099ed711e88fde
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jagdish-Gediya/kobject-Refactor-kobject_set_name_vargs/20220506-213448
git checkout 4aac95bc8a052e61d5013a25a2099ed711e88fde
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=um SUBARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

mm/util.c: In function 'set_name_vargs':
>> mm/util.c:128:9: warning: function 'set_name_vargs' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
128 | s = kvasprintf_const(GFP_KERNEL, fmt, vargs);
| ^


vim +128 mm/util.c

114
115 /**
116 * set_name_vargs() - Set the name as per format
117 * @name: pointer to point to the name as per format
118 * @fmt: format string used to build the name
119 * @vargs: vargs to format the string.
120 */
121 int set_name_vargs(const char **name, const char *fmt, va_list vargs)
122 {
123 const char *s;
124
125 if (*name && !fmt)
126 return 0;
127
> 128 s = kvasprintf_const(GFP_KERNEL, fmt, vargs);
129 if (!s)
130 return -ENOMEM;
131
132 /*
133 * ewww... some of these buggers have '/' in the name ... If
134 * that's the case, we need to make sure we have an actual
135 * allocated copy to modify, since kvasprintf_const may have
136 * returned something from .rodata.
137 */
138 if (strchr(s, '/')) {
139 char *t;
140
141 t = kstrdup(s, GFP_KERNEL);
142 kfree_const(s);
143 if (!t)
144 return -ENOMEM;
145 strreplace(t, '/', '!');
146 s = t;
147 }
148 kfree_const(*name);
149 *name = s;
150
151 return 0;
152 }
153 EXPORT_SYMBOL(set_name_vargs);
154

--
0-DAY CI Kernel Test Service
https://01.org/lkp