fs/namei: fix possible uninitialized use of inode
PATCH 1/1 fs/namei: fix possible uninitialized use of inode
commit 12f8ad4b0533d9212cb1d5e58ed73d2170114785 introduces a path which might lead to uninitialized use.
fs/namei.c: In function ‘walk_component’:fs/namei.c:1293:6: warning: ‘inode’ may be used uninitialized in this function [-Wuninitialized] fs/namei.c:1308:16: note: ‘inode’ was declared here
The commit mentioned above removed this:
*inode = nd->inode;
And now there's a possible that path looks like this:
...
1147 dentry = __d_lookup_rcu(parent, name, &seq, nd->inode);
1148 if (!dentry)
1149 goto unlazy;
...
1187 unlazy:
...
1204 if (unlikely(status <= 0)) {
1205 if (status < 0) {
1206 dput(dentry);
1207 return status;
1208 }
1209 if (!d_invalidate(dentry)) {
1210 dput(dentry);
1211 goto need_lookup;
1212 }
1213 }
So we might return 0 to walk_component, which does this compare right after check the return code from do_lookup:
1312: if (!inode) {--- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namei.c +1 -1
@@ -1295,7 +1295,7 @@ static inline int should_follow_link(struct inode *inode, int follow)static inline int walk_component (struct nameidata *nd,struct path *path,struct qstr *name,int type,int follow) { -struct inode *inode; +struct inode *inode =NULL ;int err;/* * "." and ".." are special - ".." especially so because it has
Signature · 1 line
1.7.10