Skip to contentSkip to conversation

fs/attr.c: fix check after use

PATCH In review Adrian Bunk 2 participants 3 messages Mar 24, 2005 – Mar 25, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/attr.c: fix check after use

This patch fixes a check after use found by the Coverity checker.

fs/attr.c renamed from fs/attr.c.old +3 -1
@@ -112,7 +112,7 @@
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
 	struct inode *inode = dentry->d_inode;
-	mode_t mode = inode->i_mode;
+	mode_t mode;
 	int error;
 	struct timespec now = current_fs_time(inode->i_sb);
 	unsigned int ia_valid = attr->ia_valid;
@@ -120,6 +120,8 @@
 	if (!inode)
 		BUG();
 
+	mode = inode->i_mode;
+
 	attr->ia_ctime = now;
 	if (!(ia_valid & ATTR_ATIME_SET))
 		attr->ia_atime = now;
#1 lore raw

fs/attr.c line 117

Quoted 10 lines · * Adrian Bunk ([email protected]) wrote:
fs/attr.c renamed from fs/attr.c.old +1 -1
@@ -112,7 +112,7 @@
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
 	struct inode *inode = dentry->d_inode;
-	mode_t mode = inode->i_mode;
+	mode_t mode;
 	int error;
 	struct timespec now = current_fs_time(inode->i_sb);

looks like same issue here too?

Quoted 7 lines
fs/attr.c renamed from fs/attr.c.old +2 -0
 	unsigned int ia_valid = attr->ia_valid;
@@ -120,6 +120,8 @@
 	if (!inode)
 		BUG();
 
+	mode = inode->i_mode;
+
#2 lore raw

PATCH 1/1 fs/attr.c: fix check after use

Quoted 14 lines · Chris Wright

fs/attr.c line 117

Quoted 10 lines · * Adrian Bunk ([email protected]) wrote:
fs/attr.c renamed from fs/attr.c.old +1 -1
@@ -112,7 +112,7 @@
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
 	struct inode *inode = dentry->d_inode;
-	mode_t mode = inode->i_mode;
+	mode_t mode;
 	int error;
 	struct timespec now = current_fs_time(inode->i_sb);

looks like same issue here too?
...

You forgot to a attach a brown paperbag. ;-)

Corrected patch below.

cu
Adrian

<-- snip -->

This patch fixes a check after use found by the Coverity checker.

fs/attr.c renamed from fs/attr.c.old +5 -2
@@ -112,14 +112,17 @@
 int notify_change(struct dentry * dentry, struct iattr * attr)
 {
 	struct inode *inode = dentry->d_inode;
-	mode_t mode = inode->i_mode;
+	mode_t mode;
 	int error;
-	struct timespec now = current_fs_time(inode->i_sb);
+	struct timespec now;
 	unsigned int ia_valid = attr->ia_valid;
 
 	if (!inode)
 		BUG();
 
+	mode = inode->i_mode;
+	now = current_fs_time(inode->i_sb);
+
 	attr->ia_ctime = now;
 	if (!(ia_valid & ATTR_ATIME_SET))
 		attr->ia_atime = now;