Skip to content

Commit 0fac3ed

Browse files
Su Huibrauner
authored andcommitted
fs/stat.c: avoid harmless garbage value problem in vfs_statx_path()
Clang static checker(scan-build) warning: fs/stat.c:287:21: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage. 287 | stat->result_mask |= STATX_MNT_ID_UNIQUE; | ~~~~~~~~~~~~~~~~~ ^ fs/stat.c:290:21: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage. 290 | stat->result_mask |= STATX_MNT_ID; When vfs_getattr() failed because of security_inode_getattr(), 'stat' is uninitialized. In this case, there is a harmless garbage problem in vfs_statx_path(). It's better to return error directly when vfs_getattr() failed, avoiding garbage value and more clearly. Signed-off-by: Su Hui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 2014c95 commit 0fac3ed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/stat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ static int vfs_statx_path(struct path *path, int flags, struct kstat *stat,
281281
u32 request_mask)
282282
{
283283
int error = vfs_getattr(path, stat, request_mask, flags);
284+
if (error)
285+
return error;
284286

285287
if (request_mask & STATX_MNT_ID_UNIQUE) {
286288
stat->mnt_id = real_mount(path->mnt)->mnt_id_unique;
@@ -302,7 +304,7 @@ static int vfs_statx_path(struct path *path, int flags, struct kstat *stat,
302304
if (S_ISBLK(stat->mode))
303305
bdev_statx(path, stat, request_mask);
304306

305-
return error;
307+
return 0;
306308
}
307309

308310
static int vfs_statx_fd(int fd, int flags, struct kstat *stat,

0 commit comments

Comments
 (0)