summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@cea.fr>2018-08-27 15:12:05 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-01 09:46:33 +0100
commitebd55db37fa7856ddc182da5587dd2189940d987 (patch)
treec7cc5438b857b9a2595eb1bd269fb3fdc6d8d80e /fs
parent79faf409b184b586f05f0b5cdee60953f5541d0b (diff)
downloadlinux-stable-ebd55db37fa7856ddc182da5587dd2189940d987.tar.gz
linux-stable-ebd55db37fa7856ddc182da5587dd2189940d987.tar.bz2
linux-stable-ebd55db37fa7856ddc182da5587dd2189940d987.zip
v9fs_dir_readdir: fix double-free on p9stat_read error
commit 81c99089bce693b94b775b6eb888115d2d540086 upstream. p9stat_read will call p9stat_free on error, we should only free the struct content on success. There also is no need to "p9stat_init" st as the read function will zero the whole struct for us anyway, so clean up the code a bit while we are here. Link: http://lkml.kernel.org/r/1535410108-20650-1-git-send-email-asmadeus@codewreck.org Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr> Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/9p/vfs_dir.c11
1 files changed, 0 insertions, 11 deletions
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index 5cc00e56206e..7d889f56b8e7 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -76,15 +76,6 @@ 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_alloc_rdir_buf - Allocate buffer used for read and readdir
* @filp: opened file structure
@@ -145,12 +136,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)
rdir->tail = n;
}
while (rdir->head < rdir->tail) {
- p9stat_init(&st);
err = p9stat_read(fid->clnt, rdir->buf + rdir->head,
rdir->tail - rdir->head, &st);
if (err) {
p9_debug(P9_DEBUG_VFS, "returned %d\n", err);
- p9stat_free(&st);
return -EIO;
}
reclen = st.size+2;