tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 18ecd30af1a8402c162cca1bd58771c0e5be7815 commit: 13e920d93e37fcaef4a9309515798a3cae9dcf19 [9440/13468] net: wwan: t7xx: Add core components compiler: m68k-linux-gcc (GCC) 11.3.0 reproduce (cppcheck warning): # apt-get install cppcheck git checkout 13e920d93e37fcaef4a9309515798a3cae9dcf19 cppcheck --quiet --enable=style,performance,portability --template=gcc FILE If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@xxxxxxxxx> cppcheck warnings: (new ones prefixed by >>) >> fs/kernfs/mount.c:337:29: warning: Local variable 'info' shadows outer variable [shadowVariable] struct kernfs_super_info *info = kernfs_info(sb); ^ fs/kernfs/mount.c:320:28: note: Shadowed declaration struct kernfs_super_info *info; ^ fs/kernfs/mount.c:337:29: note: Shadow variable struct kernfs_super_info *info = kernfs_info(sb); ^ cppcheck possible warnings: (new ones prefixed by >>, may not real problems) >> fs/kernfs/mount.c:174:32: warning: Parameter 'parent' can be declared with const [constParameter] struct kernfs_node *parent) ^ -- >> drivers/net/wwan/t7xx/t7xx_hif_cldma.c:370:16: warning: Uninitialized variable: req_cur->mapped_buff [uninitvar] if (req_cur->mapped_buff && req_cur->skb) { ^ >> drivers/net/wwan/t7xx/t7xx_hif_cldma.c:786:12: warning: Uninitialized variable: req->skb [uninitvar] if (req->skb) { ^ -- >> net/tls/tls_main.c:257:32: warning: Parameter 'sk' can be declared with const [constParameter] void tls_ctx_free(struct sock *sk, struct tls_context *ctx) ^ vim +/info +337 fs/kernfs/mount.c 0c23b2259a4850 Tejun Heo 2014-02-03 164 fb3c8315650f89 Aditya Kali 2016-01-29 165 /* fb3c8315650f89 Aditya Kali 2016-01-29 166 * find the next ancestor in the path down to @child, where @parent was the fb3c8315650f89 Aditya Kali 2016-01-29 167 * ancestor whose descendant we want to find. fb3c8315650f89 Aditya Kali 2016-01-29 168 * fb3c8315650f89 Aditya Kali 2016-01-29 169 * Say the path is /a/b/c/d. @child is d, @parent is NULL. We return the root fb3c8315650f89 Aditya Kali 2016-01-29 170 * node. If @parent is b, then we return the node for c. fb3c8315650f89 Aditya Kali 2016-01-29 171 * Passing in d as @parent is not ok. fb3c8315650f89 Aditya Kali 2016-01-29 172 */ fb3c8315650f89 Aditya Kali 2016-01-29 173 static struct kernfs_node *find_next_ancestor(struct kernfs_node *child, fb3c8315650f89 Aditya Kali 2016-01-29 @174 struct kernfs_node *parent) fb3c8315650f89 Aditya Kali 2016-01-29 175 { fb3c8315650f89 Aditya Kali 2016-01-29 176 if (child == parent) { fb3c8315650f89 Aditya Kali 2016-01-29 177 pr_crit_once("BUG in find_next_ancestor: called with parent == child"); fb3c8315650f89 Aditya Kali 2016-01-29 178 return NULL; fb3c8315650f89 Aditya Kali 2016-01-29 179 } fb3c8315650f89 Aditya Kali 2016-01-29 180 fb3c8315650f89 Aditya Kali 2016-01-29 181 while (child->parent != parent) { fb3c8315650f89 Aditya Kali 2016-01-29 182 if (!child->parent) fb3c8315650f89 Aditya Kali 2016-01-29 183 return NULL; fb3c8315650f89 Aditya Kali 2016-01-29 184 child = child->parent; fb3c8315650f89 Aditya Kali 2016-01-29 185 } fb3c8315650f89 Aditya Kali 2016-01-29 186 fb3c8315650f89 Aditya Kali 2016-01-29 187 return child; fb3c8315650f89 Aditya Kali 2016-01-29 188 } fb3c8315650f89 Aditya Kali 2016-01-29 189 fb3c8315650f89 Aditya Kali 2016-01-29 190 /** fb3c8315650f89 Aditya Kali 2016-01-29 191 * kernfs_node_dentry - get a dentry for the given kernfs_node fb3c8315650f89 Aditya Kali 2016-01-29 192 * @kn: kernfs_node for which a dentry is needed fb3c8315650f89 Aditya Kali 2016-01-29 193 * @sb: the kernfs super_block fb3c8315650f89 Aditya Kali 2016-01-29 194 */ fb3c8315650f89 Aditya Kali 2016-01-29 195 struct dentry *kernfs_node_dentry(struct kernfs_node *kn, fb3c8315650f89 Aditya Kali 2016-01-29 196 struct super_block *sb) fb3c8315650f89 Aditya Kali 2016-01-29 197 { fb3c8315650f89 Aditya Kali 2016-01-29 198 struct dentry *dentry; fb3c8315650f89 Aditya Kali 2016-01-29 199 struct kernfs_node *knparent = NULL; fb3c8315650f89 Aditya Kali 2016-01-29 200 fb3c8315650f89 Aditya Kali 2016-01-29 201 BUG_ON(sb->s_op != &kernfs_sops); fb3c8315650f89 Aditya Kali 2016-01-29 202 fb3c8315650f89 Aditya Kali 2016-01-29 203 dentry = dget(sb->s_root); fb3c8315650f89 Aditya Kali 2016-01-29 204 fb3c8315650f89 Aditya Kali 2016-01-29 205 /* Check if this is the root kernfs_node */ fb3c8315650f89 Aditya Kali 2016-01-29 206 if (!kn->parent) fb3c8315650f89 Aditya Kali 2016-01-29 207 return dentry; fb3c8315650f89 Aditya Kali 2016-01-29 208 fb3c8315650f89 Aditya Kali 2016-01-29 209 knparent = find_next_ancestor(kn, NULL); 399504e21a10be Al Viro 2019-01-06 210 if (WARN_ON(!knparent)) { 399504e21a10be Al Viro 2019-01-06 211 dput(dentry); fb3c8315650f89 Aditya Kali 2016-01-29 212 return ERR_PTR(-EINVAL); 399504e21a10be Al Viro 2019-01-06 213 } fb3c8315650f89 Aditya Kali 2016-01-29 214 fb3c8315650f89 Aditya Kali 2016-01-29 215 do { fb3c8315650f89 Aditya Kali 2016-01-29 216 struct dentry *dtmp; fb3c8315650f89 Aditya Kali 2016-01-29 217 struct kernfs_node *kntmp; fb3c8315650f89 Aditya Kali 2016-01-29 218 fb3c8315650f89 Aditya Kali 2016-01-29 219 if (kn == knparent) fb3c8315650f89 Aditya Kali 2016-01-29 220 return dentry; fb3c8315650f89 Aditya Kali 2016-01-29 221 kntmp = find_next_ancestor(kn, knparent); 399504e21a10be Al Viro 2019-01-06 222 if (WARN_ON(!kntmp)) { 399504e21a10be Al Viro 2019-01-06 223 dput(dentry); fb3c8315650f89 Aditya Kali 2016-01-29 224 return ERR_PTR(-EINVAL); 399504e21a10be Al Viro 2019-01-06 225 } 6c2d4798a8d16c Al Viro 2019-10-31 226 dtmp = lookup_positive_unlocked(kntmp->name, dentry, 779b839133d7ab Al Viro 2016-04-11 227 strlen(kntmp->name)); fb3c8315650f89 Aditya Kali 2016-01-29 228 dput(dentry); fb3c8315650f89 Aditya Kali 2016-01-29 229 if (IS_ERR(dtmp)) fb3c8315650f89 Aditya Kali 2016-01-29 230 return dtmp; fb3c8315650f89 Aditya Kali 2016-01-29 231 knparent = kntmp; fb3c8315650f89 Aditya Kali 2016-01-29 232 dentry = dtmp; fb3c8315650f89 Aditya Kali 2016-01-29 233 } while (true); fb3c8315650f89 Aditya Kali 2016-01-29 234 } fb3c8315650f89 Aditya Kali 2016-01-29 235 23bf1b6be9c291 David Howells 2018-11-01 236 static int kernfs_fill_super(struct super_block *sb, struct kernfs_fs_context *kfc) fa736a951e456b Tejun Heo 2013-11-28 237 { c525aaddc366df Tejun Heo 2013-12-11 238 struct kernfs_super_info *info = kernfs_info(sb); 393c3714081a53 Minchan Kim 2021-11-18 239 struct kernfs_root *kf_root = kfc->root; fa736a951e456b Tejun Heo 2013-11-28 240 struct inode *inode; fa736a951e456b Tejun Heo 2013-11-28 241 struct dentry *root; fa736a951e456b Tejun Heo 2013-11-28 242 7d568a8383bbb9 Tejun Heo 2014-04-09 243 info->sb = sb; a2982cc922c306 Eric W. Biederman 2016-06-09 244 /* Userspace would break if executables or devices appear on sysfs */ a2982cc922c306 Eric W. Biederman 2016-06-09 245 sb->s_iflags |= SB_I_NOEXEC | SB_I_NODEV; 09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 246 sb->s_blocksize = PAGE_SIZE; 09cbfeaf1a5a67 Kirill A. Shutemov 2016-04-01 247 sb->s_blocksize_bits = PAGE_SHIFT; 23bf1b6be9c291 David Howells 2018-11-01 248 sb->s_magic = kfc->magic; a797bfc3053238 Tejun Heo 2013-12-11 249 sb->s_op = &kernfs_sops; e72a1a8b3a5a2a Andreas Gruenbacher 2016-09-29 250 sb->s_xattr = kernfs_xattr_handlers; aa8188253474b4 Shaohua Li 2017-07-12 251 if (info->root->flags & KERNFS_ROOT_SUPPORT_EXPORTOP) aa8188253474b4 Shaohua Li 2017-07-12 252 sb->s_export_op = &kernfs_export_ops; fa736a951e456b Tejun Heo 2013-11-28 253 sb->s_time_gran = 1; fa736a951e456b Tejun Heo 2013-11-28 254 4b85afbdacd290 Johannes Weiner 2018-10-26 255 /* sysfs dentries and inodes don't require IO to create */ 4b85afbdacd290 Johannes Weiner 2018-10-26 256 sb->s_shrink.seeks = 0; 4b85afbdacd290 Johannes Weiner 2018-10-26 257 fa736a951e456b Tejun Heo 2013-11-28 258 /* get root inode, initialize and unlock it */ 393c3714081a53 Minchan Kim 2021-11-18 259 down_read(&kf_root->kernfs_rwsem); c637b8acbe079e Tejun Heo 2013-12-11 260 inode = kernfs_get_inode(sb, info->root->kn); 393c3714081a53 Minchan Kim 2021-11-18 261 up_read(&kf_root->kernfs_rwsem); fa736a951e456b Tejun Heo 2013-11-28 262 if (!inode) { c637b8acbe079e Tejun Heo 2013-12-11 263 pr_debug("kernfs: could not get root inode\n"); fa736a951e456b Tejun Heo 2013-11-28 264 return -ENOMEM; fa736a951e456b Tejun Heo 2013-11-28 265 } fa736a951e456b Tejun Heo 2013-11-28 266 fa736a951e456b Tejun Heo 2013-11-28 267 /* instantiate and link root dentry */ fa736a951e456b Tejun Heo 2013-11-28 268 root = d_make_root(inode); fa736a951e456b Tejun Heo 2013-11-28 269 if (!root) { fa736a951e456b Tejun Heo 2013-11-28 270 pr_debug("%s: could not get root dentry!\n", __func__); fa736a951e456b Tejun Heo 2013-11-28 271 return -ENOMEM; fa736a951e456b Tejun Heo 2013-11-28 272 } fa736a951e456b Tejun Heo 2013-11-28 273 sb->s_root = root; a797bfc3053238 Tejun Heo 2013-12-11 274 sb->s_d_op = &kernfs_dops; fa736a951e456b Tejun Heo 2013-11-28 275 return 0; fa736a951e456b Tejun Heo 2013-11-28 276 } fa736a951e456b Tejun Heo 2013-11-28 277 23bf1b6be9c291 David Howells 2018-11-01 278 static int kernfs_test_super(struct super_block *sb, struct fs_context *fc) fa736a951e456b Tejun Heo 2013-11-28 279 { c525aaddc366df Tejun Heo 2013-12-11 280 struct kernfs_super_info *sb_info = kernfs_info(sb); 23bf1b6be9c291 David Howells 2018-11-01 281 struct kernfs_super_info *info = fc->s_fs_info; fa736a951e456b Tejun Heo 2013-11-28 282 fa736a951e456b Tejun Heo 2013-11-28 283 return sb_info->root == info->root && sb_info->ns == info->ns; fa736a951e456b Tejun Heo 2013-11-28 284 } fa736a951e456b Tejun Heo 2013-11-28 285 23bf1b6be9c291 David Howells 2018-11-01 286 static int kernfs_set_super(struct super_block *sb, struct fs_context *fc) fa736a951e456b Tejun Heo 2013-11-28 287 { 23bf1b6be9c291 David Howells 2018-11-01 288 struct kernfs_fs_context *kfc = fc->fs_private; 23bf1b6be9c291 David Howells 2018-11-01 289 23bf1b6be9c291 David Howells 2018-11-01 290 kfc->ns_tag = NULL; 23bf1b6be9c291 David Howells 2018-11-01 291 return set_anon_super_fc(sb, fc); fa736a951e456b Tejun Heo 2013-11-28 292 } fa736a951e456b Tejun Heo 2013-11-28 293 fa736a951e456b Tejun Heo 2013-11-28 294 /** fa736a951e456b Tejun Heo 2013-11-28 295 * kernfs_super_ns - determine the namespace tag of a kernfs super_block fa736a951e456b Tejun Heo 2013-11-28 296 * @sb: super_block of interest fa736a951e456b Tejun Heo 2013-11-28 297 * fa736a951e456b Tejun Heo 2013-11-28 298 * Return the namespace tag associated with kernfs super_block @sb. fa736a951e456b Tejun Heo 2013-11-28 299 */ fa736a951e456b Tejun Heo 2013-11-28 300 const void *kernfs_super_ns(struct super_block *sb) fa736a951e456b Tejun Heo 2013-11-28 301 { c525aaddc366df Tejun Heo 2013-12-11 302 struct kernfs_super_info *info = kernfs_info(sb); fa736a951e456b Tejun Heo 2013-11-28 303 fa736a951e456b Tejun Heo 2013-11-28 304 return info->ns; fa736a951e456b Tejun Heo 2013-11-28 305 } fa736a951e456b Tejun Heo 2013-11-28 306 fa736a951e456b Tejun Heo 2013-11-28 307 /** 23bf1b6be9c291 David Howells 2018-11-01 308 * kernfs_get_tree - kernfs filesystem access/retrieval helper 23bf1b6be9c291 David Howells 2018-11-01 309 * @fc: The filesystem context. fa736a951e456b Tejun Heo 2013-11-28 310 * 23bf1b6be9c291 David Howells 2018-11-01 311 * This is to be called from each kernfs user's fs_context->ops->get_tree() 23bf1b6be9c291 David Howells 2018-11-01 312 * implementation, which should set the specified ->@fs_type and ->@flags, and 23bf1b6be9c291 David Howells 2018-11-01 313 * specify the hierarchy and namespace tag to mount via ->@root and ->@ns, 23bf1b6be9c291 David Howells 2018-11-01 314 * respectively. fa736a951e456b Tejun Heo 2013-11-28 315 */ 23bf1b6be9c291 David Howells 2018-11-01 316 int kernfs_get_tree(struct fs_context *fc) fa736a951e456b Tejun Heo 2013-11-28 317 { 23bf1b6be9c291 David Howells 2018-11-01 318 struct kernfs_fs_context *kfc = fc->fs_private; fa736a951e456b Tejun Heo 2013-11-28 319 struct super_block *sb; c525aaddc366df Tejun Heo 2013-12-11 320 struct kernfs_super_info *info; fa736a951e456b Tejun Heo 2013-11-28 321 int error; fa736a951e456b Tejun Heo 2013-11-28 322 fa736a951e456b Tejun Heo 2013-11-28 323 info = kzalloc(sizeof(*info), GFP_KERNEL); fa736a951e456b Tejun Heo 2013-11-28 324 if (!info) 23bf1b6be9c291 David Howells 2018-11-01 325 return -ENOMEM; fa736a951e456b Tejun Heo 2013-11-28 326 23bf1b6be9c291 David Howells 2018-11-01 327 info->root = kfc->root; 23bf1b6be9c291 David Howells 2018-11-01 328 info->ns = kfc->ns_tag; 82382acec0c97b Al Viro 2018-04-03 329 INIT_LIST_HEAD(&info->node); fa736a951e456b Tejun Heo 2013-11-28 330 23bf1b6be9c291 David Howells 2018-11-01 331 fc->s_fs_info = info; 23bf1b6be9c291 David Howells 2018-11-01 332 sb = sget_fc(fc, kernfs_test_super, kernfs_set_super); fa736a951e456b Tejun Heo 2013-11-28 333 if (IS_ERR(sb)) 23bf1b6be9c291 David Howells 2018-11-01 334 return PTR_ERR(sb); fed95bab8d29b9 Li Zefan 2014-02-25 335 fa736a951e456b Tejun Heo 2013-11-28 336 if (!sb->s_root) { 7d568a8383bbb9 Tejun Heo 2014-04-09 @337 struct kernfs_super_info *info = kernfs_info(sb); 393c3714081a53 Minchan Kim 2021-11-18 338 struct kernfs_root *root = kfc->root; 7d568a8383bbb9 Tejun Heo 2014-04-09 339 23bf1b6be9c291 David Howells 2018-11-01 340 kfc->new_sb_created = true; 23bf1b6be9c291 David Howells 2018-11-01 341 23bf1b6be9c291 David Howells 2018-11-01 342 error = kernfs_fill_super(sb, kfc); fa736a951e456b Tejun Heo 2013-11-28 343 if (error) { fa736a951e456b Tejun Heo 2013-11-28 344 deactivate_locked_super(sb); 23bf1b6be9c291 David Howells 2018-11-01 345 return error; fa736a951e456b Tejun Heo 2013-11-28 346 } 1751e8a6cb935e Linus Torvalds 2017-11-27 347 sb->s_flags |= SB_ACTIVE; 7d568a8383bbb9 Tejun Heo 2014-04-09 348 393c3714081a53 Minchan Kim 2021-11-18 349 down_write(&root->kernfs_rwsem); 23bf1b6be9c291 David Howells 2018-11-01 350 list_add(&info->node, &info->root->supers); 393c3714081a53 Minchan Kim 2021-11-18 351 up_write(&root->kernfs_rwsem); fa736a951e456b Tejun Heo 2013-11-28 352 } fa736a951e456b Tejun Heo 2013-11-28 353 23bf1b6be9c291 David Howells 2018-11-01 354 fc->root = dget(sb->s_root); 23bf1b6be9c291 David Howells 2018-11-01 355 return 0; 23bf1b6be9c291 David Howells 2018-11-01 356 } 23bf1b6be9c291 David Howells 2018-11-01 357 :::::: The code at line 337 was first introduced by commit :::::: 7d568a8383bbb9c1f5167781075906acb2bb1550 kernfs: implement kernfs_root->supers list :::::: TO: Tejun Heo <tj@xxxxxxxxxx> :::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> -- 0-DAY CI Kernel Test Service https://01.org/lkp