patch attached to set ppath to null by default On Sat, Jun 4, 2022 at 12:22 AM Steven French <Steven.French@xxxxxxxxxxxxx> wrote: > > > > Get Outlook for Android > ________________________________ > From: kernel test robot <lkp@xxxxxxxxx> > Sent: Friday, June 3, 2022 10:00:31 PM > To: pc <pc@xxxxxx> > Cc: llvm@xxxxxxxxxxxxxxx <llvm@xxxxxxxxxxxxxxx>; kbuild-all@xxxxxxxxxxxx <kbuild-all@xxxxxxxxxxxx>; linux-cifs@xxxxxxxxxxxxxxx <linux-cifs@xxxxxxxxxxxxxxx>; samba-technical@xxxxxxxxxxxxxxx <samba-technical@xxxxxxxxxxxxxxx>; Steven French <Steven.French@xxxxxxxxxxxxx> > 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@xxxxxxxxx> > > 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
From 46ce69662169e10ff621aea0e368d30abbe6ac99 Mon Sep 17 00:00:00 2001 From: Steve French <stfrench@xxxxxxxxxxxxx> 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@xxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> --- 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