Skip to content

Commit

Permalink
fs/9p: re-init the wstat in readdir loop
Browse files Browse the repository at this point in the history
This ensure that on failure when we free the stat buf we don't end up
freeing an already freed pointer in the earlier loop

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Aneesh Kumar K.V authored and Eric Van Hensbergen committed Mar 13, 2010
1 parent 86c8437 commit fae4528
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/9p/vfs_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ static inline int dt_type(struct p9_wstat *mistat)
return rettype;
}

static void p9stat_init(struct p9_wstat *stbuf)
{
stbuf->name = NULL;
stbuf->uid = NULL;
stbuf->gid = NULL;
stbuf->muid = NULL;
stbuf->extension = NULL;
}

/**
* v9fs_dir_readdir - read a directory
* @filp: opened file structure
Expand Down Expand Up @@ -131,8 +140,8 @@ static int v9fs_dir_readdir(struct file *filp, void *dirent, filldir_t filldir)
rdir->head = 0;
rdir->tail = err;
}

while (rdir->head < rdir->tail) {
p9stat_init(&st);
err = p9stat_read(rdir->buf + rdir->head,
buflen - rdir->head, &st,
fid->clnt->proto_version);
Expand Down

0 comments on commit fae4528

Please sign in to comment.