* [cifs:for-next 8/8] fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false
@ 2022-06-04 5:00 kernel test robot
[not found] ` <DM6PR21MB1466F4E4127EADC233ACC794E4A09@DM6PR21MB1466.namprd21.prod.outlook.com>
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2022-06-04 5:00 UTC (permalink / raw)
To: Paulo Alcantara
Cc: llvm, kbuild-all, linux-cifs, samba-technical, Steve French
tree: git://git.samba.org/sfrench/cifs-2.6.git for-next
head: ef605e86821253d16d47a02ce1f766a461614fef
commit: ef605e86821253d16d47a02ce1f766a461614fef [8/8] cifs: skip trailing separators of prefix paths
config: arm-randconfig-c002-20220603 (https://download.01.org/0day-ci/archive/20220604/202206041223.Kx81JSQt-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b364c76683f8ef241025a9556300778c07b590c2)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
git remote add cifs git://git.samba.org/sfrench/cifs-2.6.git
git fetch --no-tags cifs for-next
git checkout ef605e86821253d16d47a02ce1f766a461614fef
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash fs/cifs/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
>> fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (target_pplen || dfsref_pplen) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:56:28: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/cifs/dfs_cache.c:1307:12: note: uninitialized use occurs here
*prefix = ppath;
^~~~~
fs/cifs/dfs_cache.c:1294:2: note: remove the 'if' if its condition is always true
if (target_pplen || dfsref_pplen) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:56:23: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
fs/cifs/dfs_cache.c:1270:28: note: initialize the variable 'ppath' to silence this warning
char *target_share, *ppath;
^
= NULL
1 warning generated.
vim +1294 fs/cifs/dfs_cache.c
1255
1256 /**
1257 * dfs_cache_get_tgt_share - parse a DFS target
1258 *
1259 * @path: DFS full path
1260 * @it: DFS target iterator.
1261 * @share: tree name.
1262 * @prefix: prefix path.
1263 *
1264 * Return zero if target was parsed correctly, otherwise non-zero.
1265 */
1266 int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
1267 char **prefix)
1268 {
1269 char sep;
1270 char *target_share, *ppath;
1271 const char *target_ppath, *dfsref_ppath;
1272 size_t target_pplen, dfsref_pplen;
1273 size_t len, c;
1274
1275 if (!it || !path || !share || !prefix || strlen(path) < it->it_path_consumed)
1276 return -EINVAL;
1277
1278 sep = it->it_name[0];
1279 if (sep != '\\' && sep != '/')
1280 return -EINVAL;
1281
1282 target_ppath = parse_target_share(it->it_name, &target_share);
1283 if (IS_ERR(target_ppath))
1284 return PTR_ERR(target_ppath);
1285
1286 /* point to prefix in DFS referral path */
1287 dfsref_ppath = path + it->it_path_consumed;
1288 dfsref_ppath += strspn(dfsref_ppath, "/\\");
1289
1290 target_pplen = strlen(target_ppath);
1291 dfsref_pplen = strlen(dfsref_ppath);
1292
1293 /* merge prefix paths from DFS referral path and target node */
> 1294 if (target_pplen || dfsref_pplen) {
1295 len = target_pplen + dfsref_pplen + 2;
1296 ppath = kzalloc(len, GFP_KERNEL);
1297 if (!ppath) {
1298 kfree(target_share);
1299 return -ENOMEM;
1300 }
1301 c = strscpy(ppath, target_ppath, len);
1302 if (c && dfsref_pplen)
1303 ppath[c] = sep;
1304 strlcat(ppath, dfsref_ppath, len);
1305 }
1306 *share = target_share;
1307 *prefix = ppath;
1308 return 0;
1309 }
1310
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 2+ messages in thread[parent not found: <DM6PR21MB1466F4E4127EADC233ACC794E4A09@DM6PR21MB1466.namprd21.prod.outlook.com>]
* Re: [EXTERNAL] [cifs:for-next 8/8] fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false [not found] ` <DM6PR21MB1466F4E4127EADC233ACC794E4A09@DM6PR21MB1466.namprd21.prod.outlook.com> @ 2022-06-04 6:23 ` Steve French 0 siblings, 0 replies; 2+ messages in thread From: Steve French @ 2022-06-04 6:23 UTC (permalink / raw) To: Steven French, Paulo Alcantara; +Cc: CIFS [-- Attachment #1: Type: text/plain, Size: 7666 bytes --] patch attached to set ppath to null by default On Sat, Jun 4, 2022 at 12:22 AM Steven French <Steven.French@microsoft.com> wrote: > > > > Get Outlook for Android > ________________________________ > From: kernel test robot <lkp@intel.com> > Sent: Friday, June 3, 2022 10:00:31 PM > To: pc <pc@cjr.nz> > Cc: llvm@lists.linux.dev <llvm@lists.linux.dev>; kbuild-all@lists.01.org <kbuild-all@lists.01.org>; linux-cifs@vger.kernel.org <linux-cifs@vger.kernel.org>; samba-technical@lists.samba.org <samba-technical@lists.samba.org>; Steven French <Steven.French@microsoft.com> > Subject: [EXTERNAL] [cifs:for-next 8/8] fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false > > tree: git://git.samba.org/sfrench/cifs-2.6.git for-next > head: ef605e86821253d16d47a02ce1f766a461614fef > commit: ef605e86821253d16d47a02ce1f766a461614fef [8/8] cifs: skip trailing separators of prefix paths > config: arm-randconfig-c002-20220603 (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdownload.01.org%2F0day-ci%2Farchive%2F20220604%2F202206041223.Kx81JSQt-lkp%40intel.com%2Fconfig&data=05%7C01%7CSteven.French%40microsoft.com%7C8fd0f93076304ca4db7408da45e74210%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637899156811777573%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=I%2FEylneaMr3LmxdLWgGMfgoePbuxH5tathKlIaR5dJU%3D&reserved=0) > compiler: clang version 15.0.0 (https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project&data=05%7C01%7CSteven.French%40microsoft.com%7C8fd0f93076304ca4db7408da45e74210%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637899156811777573%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=IIT72ydb3VXEpUd8pYus96zzwjWnvHcHJgP4uFbLI2U%3D&reserved=0 b364c76683f8ef241025a9556300778c07b590c2) > reproduce (this is a W=1 build): > wget https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fintel%2Flkp-tests%2Fmaster%2Fsbin%2Fmake.cross&data=05%7C01%7CSteven.French%40microsoft.com%7C8fd0f93076304ca4db7408da45e74210%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637899156811777573%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rWO79li71JswarF6XxfENQwmBdCbcQ4sG5m%2FhQCcl3M%3D&reserved=0 -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install arm cross compiling tool for clang build > # apt-get install binutils-arm-linux-gnueabi > git remote add cifs git://git.samba.org/sfrench/cifs-2.6.git > git fetch --no-tags cifs for-next > git checkout ef605e86821253d16d47a02ce1f766a461614fef > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash fs/cifs/ > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot <lkp@intel.com> > > All warnings (new ones prefixed by >>): > > >> fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] > if (target_pplen || dfsref_pplen) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/compiler.h:56:28: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > fs/cifs/dfs_cache.c:1307:12: note: uninitialized use occurs here > *prefix = ppath; > ^~~~~ > fs/cifs/dfs_cache.c:1294:2: note: remove the 'if' if its condition is always true > if (target_pplen || dfsref_pplen) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/compiler.h:56:23: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^ > fs/cifs/dfs_cache.c:1270:28: note: initialize the variable 'ppath' to silence this warning > char *target_share, *ppath; > ^ > = NULL > 1 warning generated. > > > vim +1294 fs/cifs/dfs_cache.c > > 1255 > 1256 /** > 1257 * dfs_cache_get_tgt_share - parse a DFS target > 1258 * > 1259 * @path: DFS full path > 1260 * @it: DFS target iterator. > 1261 * @share: tree name. > 1262 * @prefix: prefix path. > 1263 * > 1264 * Return zero if target was parsed correctly, otherwise non-zero. > 1265 */ > 1266 int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share, > 1267 char **prefix) > 1268 { > 1269 char sep; > 1270 char *target_share, *ppath; > 1271 const char *target_ppath, *dfsref_ppath; > 1272 size_t target_pplen, dfsref_pplen; > 1273 size_t len, c; > 1274 > 1275 if (!it || !path || !share || !prefix || strlen(path) < it->it_path_consumed) > 1276 return -EINVAL; > 1277 > 1278 sep = it->it_name[0]; > 1279 if (sep != '\\' && sep != '/') > 1280 return -EINVAL; > 1281 > 1282 target_ppath = parse_target_share(it->it_name, &target_share); > 1283 if (IS_ERR(target_ppath)) > 1284 return PTR_ERR(target_ppath); > 1285 > 1286 /* point to prefix in DFS referral path */ > 1287 dfsref_ppath = path + it->it_path_consumed; > 1288 dfsref_ppath += strspn(dfsref_ppath, "/\\"); > 1289 > 1290 target_pplen = strlen(target_ppath); > 1291 dfsref_pplen = strlen(dfsref_ppath); > 1292 > 1293 /* merge prefix paths from DFS referral path and target node */ > > 1294 if (target_pplen || dfsref_pplen) { > 1295 len = target_pplen + dfsref_pplen + 2; > 1296 ppath = kzalloc(len, GFP_KERNEL); > 1297 if (!ppath) { > 1298 kfree(target_share); > 1299 return -ENOMEM; > 1300 } > 1301 c = strscpy(ppath, target_ppath, len); > 1302 if (c && dfsref_pplen) > 1303 ppath[c] = sep; > 1304 strlcat(ppath, dfsref_ppath, len); > 1305 } > 1306 *share = target_share; > 1307 *prefix = ppath; > 1308 return 0; > 1309 } > 1310 > > -- > 0-DAY CI Kernel Test Service > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2F01.org%2Flkp&data=05%7C01%7CSteven.French%40microsoft.com%7C8fd0f93076304ca4db7408da45e74210%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637899156811777573%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DA%2FZslJz3uARiZHC0HxgSP3ccOYqv%2B%2FUh68fCZm3Fgk%3D&reserved=0 -- Thanks, Steve [-- Attachment #2: 0001-cifs-fix-uninitialized-pointer-in-error-case-in-dfs_.patch --] [-- Type: text/x-patch, Size: 934 bytes --] From 46ce69662169e10ff621aea0e368d30abbe6ac99 Mon Sep 17 00:00:00 2001 From: Steve French <stfrench@microsoft.com> Date: Sat, 4 Jun 2022 01:18:37 -0500 Subject: [PATCH] cifs: fix uninitialized pointer in error case in dfs_cache_get_tgt_share Set default value of ppath to null. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Steve French <stfrench@microsoft.com> --- fs/cifs/dfs_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c index 7b978a126268..34a8f3baed5e 100644 --- a/fs/cifs/dfs_cache.c +++ b/fs/cifs/dfs_cache.c @@ -1267,7 +1267,8 @@ int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **prefix) { char sep; - char *target_share, *ppath; + char *target_share; + char *ppath = NULL; const char *target_ppath, *dfsref_ppath; size_t target_pplen, dfsref_pplen; size_t len, c; -- 2.34.1 ^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-04 6:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-04 5:00 [cifs:for-next 8/8] fs/cifs/dfs_cache.c:1294:2: warning: variable 'ppath' is used uninitialized whenever 'if' condition is false kernel test robot
[not found] ` <DM6PR21MB1466F4E4127EADC233ACC794E4A09@DM6PR21MB1466.namprd21.prod.outlook.com>
2022-06-04 6:23 ` [EXTERNAL] " Steve French
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox