[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] 9pfs: fix memory leak in v9fs_xattrcreate
From: |
Greg Kurz |
Subject: |
Re: [Qemu-devel] [PATCH] 9pfs: fix memory leak in v9fs_xattrcreate |
Date: |
Mon, 10 Oct 2016 13:28:33 +0200 |
On Mon, 10 Oct 2016 13:20:51 +0200
Greg Kurz <address@hidden> wrote:
> On Mon, 10 Oct 2016 03:41:38 -0700
> Li Qiang <address@hidden> wrote:
>
> > From: Li Qiang <address@hidden>
> >
> > The 'fs.xattr.value' field in V9fsFidState object doesn't consider the
> > situation that this field has been allocated previously. Every time, it
> > will be allocated directly. This leads a host memory leak issue. This
> > patch fix this.
> >
> > Signed-off-by: Li Qiang <address@hidden>
> > ---
>
> I'll add to the changelog that this may happen if the client sends a
> Txattrcreate message with the same fid number before the fid was
> clunked.
>
> Reviewed-by: Greg Kurz <address@hidden>
>
Oops I may have answered to fast... what about xattr_fidp->fs.xattr.name ?
It looks like it is leaked the same way...
> > hw/9pfs/9p.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 8751c19..e4040dc 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -3282,6 +3282,7 @@ static void v9fs_xattrcreate(void *opaque)
> > xattr_fidp->fs.xattr.flags = flags;
> > v9fs_string_init(&xattr_fidp->fs.xattr.name);
> > v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
> > + g_free(xattr_fidp->fs.xattr.value);
> > xattr_fidp->fs.xattr.value = g_malloc0(size);
> > err = offset;
> > put_fid(pdu, file_fidp);
>