Re: [PATCH v2] 9p: avoid returning ERR_PTR(0) from mkdir operations

Dominique Martinet <[email protected]> Fri, 29 May 2026 10:55:34 +0900
Newsgroups dev.linux.lists.v9fs,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hongling Zeng wrote on Wed, May 20, 2026 at 10:26:50AM +0800:
> 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'
> 
> This change does not alter the runtime behavior since ERR_PTR(0) and NULL
> are equivalent. However, it improves code readability and silences static
> analyzer warnings.
> 
> Fixes: 88d5baf69082 ("Change inode_operations.mkdir to return struct dentry *")
> Suggested-by: David Laight <[email protected]>
> Acked-by: Christian Schoenebeck <[email protected]>
> Signed-off-by: Hongling Zeng <[email protected]>

Thanks for the v2, this looks correct to me.

The commit message should mention that v9fs_create() never returns NULL
and v9fs_vfs_mkdir() can be simplified accordingly, but I'll fix that on
my end

-- 
Dominique