Skip to contentSkip to conversation

New Defects reported by Coverity Scan for linux-next weekly scan (fwd)

DISCUSSION Jan Kara 1 participant 1 message Oct 9, 2024 VFS

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

I've got this complaint from coverity:

----- Forwarded message from [email protected] -----

________________________________________________________________________________________________________
*** CID 1600337: (UNINIT)
/fs/attr.c: 311 in setattr_copy_mgtime()
305 else if (ia_valid & ATTR_ATIME)
306 inode_set_atime_to_ts(inode, now);
307

308     	if (ia_valid & ATTR_MTIME_SET)
309     		inode_set_mtime_to_ts(inode, attr->ia_mtime);
310     	else if (ia_valid & ATTR_MTIME)
>>>     CID 1600337:    (UNINIT)
>>>     Using uninitialized value "now" when calling "inode_set_mtime_to_ts".
311     		inode_set_mtime_to_ts(inode, now);
312     }

313
314 /**
315 * setattr_copy - copy simple metadata updates into the generic inode
316 * @idmap: idmap of the mount the inode was found from
/fs/attr.c: 306 in setattr_copy_mgtime()
300 WARN_ON_ONCE(ia_valid & ATTR_MTIME);
301 }
302

303     	if (ia_valid & ATTR_ATIME_SET)
304     		inode_set_atime_to_ts(inode, attr->ia_atime);
305     	else if (ia_valid & ATTR_ATIME)
>>>     CID 1600337:    (UNINIT)
>>>     Using uninitialized value "now" when calling "inode_set_atime_to_ts".
306     		inode_set_atime_to_ts(inode, now);
307     
308     	if (ia_valid & ATTR_MTIME_SET)
309     		inode_set_mtime_to_ts(inode, attr->ia_mtime);
310     	else if (ia_valid & ATTR_MTIME)
311     		inode_set_mtime_to_ts(inode, now);

Now we WARN if ATTR_MTIME is set without ATTR_CTIME but still it might be good to place some sane value in 'now' so that we don't set the timestamp to garbage and more importantly setting ATTR_ATIME without ATTR_CTIME looks as a possible thing?

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR