]> git.ipfire.org Git - thirdparty/linux.git/commit
9p: avoid returning ERR_PTR(0) from mkdir operations
authorHongling Zeng <zenghongling@kylinos.cn>
Wed, 20 May 2026 02:26:50 +0000 (10:26 +0800)
committerDominique Martinet <asmadeus@codewreck.org>
Sun, 21 Jun 2026 05:22:56 +0000 (05:22 +0000)
commit314b58c01a9047567fd19446ca5fd46c473b89ff
tree52df2bea6db8f174e5348122c452b718915cebb9
parent1a3860d46e3eb47dbd60339783cdad7904486b9f
9p: avoid returning ERR_PTR(0) from mkdir operations

When mkdir succeeds, v9fs_vfs_mkdir_dotl() and v9fs_vfs_mkdir() return
ERR_PTR(0) which is incorrect. They should return NULL instead for
success and ERR_PTR() only with negative error codes for failure.

Return NULL instead of passing to ERR_PTR while err is zero
Fixes smatch warnings:
  fs/9p/vfs_inode_dotl.c:420 v9fs_vfs_mkdir_dotl() warn: passing zero to 'ERR_PTR'
  fs/9p/vfs_inode.c:695 v9fs_vfs_mkdir() warn: passing zero to 'ERR_PTR'

The v9fs_vfs_mkdir() code was further simplified because v9fs_create()
can never return NULL, so we do not need to check for fid being set
separately, and the error path can be a simple return immediately after
v9fs_create() failure.
There is no intended functional change.

Fixes: 88d5baf69082 ("Change inode_operations.mkdir to return struct dentry *")
Suggested-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Message-ID: <20260520022650.14217-1-zenghongling@kylinos.cn>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c