fs/9p: mitigate inode collisions
Hello Eric Van Hensbergen,
Commit 6ae7784008d9 (" fs/9p: mitigate inode collisions") from Apr 15, 2024 (linux-next), leads to the following Smatch static checker warning:
fs/9p/vfs_inode.c:513 v9fs_remove() error: uninitialized symbol 'v9fid'.
fs/9p/vfs_inode.c
470 static int v9fs_remove(struct inode *dir, struct dentry *dentry, int flags)
471 {
472 struct inode *inode;
473 int retval = -EOPNOTSUPP;
474 struct p9_fid *v9fid, *dfid;
475 struct v9fs_session_info *v9ses;
476
477 p9_debug(P9_DEBUG_VFS, "inode: %p dentry: %p rmdir: %x\n",
478 dir, dentry, flags);
479
480 v9ses = v9fs_inode2v9ses(dir);
481 inode = d_inode(dentry);
482 dfid = v9fs_parent_fid(dentry);
483 if (IS_ERR(dfid)) {
484 retval = PTR_ERR(dfid);
485 p9_debug(P9_DEBUG_VFS, "fid lookup failed %d\n", retval);
486 return retval;
487 }
488 if (v9fs_proto_dotl(v9ses))
489 retval = p9_client_unlinkat(dfid, dentry->d_name.name,
490 v9fs_at_to_dotl_flags(flags));
491 p9_fid_put(dfid);
492 if (retval == -EOPNOTSUPP) {
493 /* Try the one based on path */
494 v9fid = v9fs_fid_clone(dentry);
495 if (IS_ERR(v9fid))
496 return PTR_ERR(v9fid);
497 retval = p9_client_remove(v9fid);
498 }v9fid is not initialized if retval != -EOPNOTSUPP.
499 if (!retval) {
500 /*
501 * directories on unlink should have zero
502 * link count
503 */
504 if (flags & AT_REMOVEDIR) {
505 clear_nlink(inode);
506 v9fs_dec_count(dir);
507 } else
508 v9fs_dec_count(inode);
509
510 if (inode->i_nlink <= 0) { /* no more refs unhash it */
511 remove_inode_hash(inode);
512 } else {
--> 513 p9_debug(P9_DEBUG_ERROR,
514 "WARNING: unlink inode %lx %s qid->path=%llx w/i_nlink==%d\n",
515 inode->i_ino, dentry->d_name.name, v9fid->qid.path, inode->i_nlink);
^^^^^^^^^^^^^^^Uninitialized.
516 }
517
518 v9fs_invalidate_inode_attr(inode);
519 v9fs_invalidate_inode_attr(dir);
520
521 /* invalidate all fids associated with dentry */
522 /* NOTE: This will not include open fids */
523 dentry->d_op->d_release(dentry);
524 }
525 return retval;
526 }regards,
dan carpenter
Eric Van Hensbergen
maintainerQuoted 10 lines · Dan Carpenter
Hello Eric Van Hensbergen,
Commit
6ae7784008d9(" fs/9p: mitigate inode collisions") from Apr 15, 2024 (linux-next), leads to the following Smatch static checker warning:
fs/9p/vfs_inode.c:513v9fs_remove()
error: uninitialized symbol 'v9fid'.
Thanks for this, I've amended the patch to remove the print in question since it was actually vestigial telemetry while I was debugging and shouldn't have been in the patch in the first place.
-eric