Received: from eggs.gnu.org ([2001:4830:134:3::10]:57888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0pK9-0003Yy-Ba for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:34:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0pK6-0001qY-8z for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:34:53 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:32834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c0pK5-0001qB-W0 for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:34:50 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9UCXOeW035420 for ; Sun, 30 Oct 2016 08:34:49 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 26dgkq0jn4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 30 Oct 2016 08:34:48 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 30 Oct 2016 12:34:46 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id D332017D805A for ; Sun, 30 Oct 2016 12:37:01 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9UCYjZI28639232 for ; Sun, 30 Oct 2016 12:34:45 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9UCYijS022083 for ; Sun, 30 Oct 2016 06:34:45 -0600 From: Greg Kurz Date: Sun, 30 Oct 2016 13:34:26 +0100 In-Reply-To: <1477830868-12274-1-git-send-email-groug@kaod.org> References: <1477830868-12274-1-git-send-email-groug@kaod.org> Message-Id: <1477830868-12274-6-git-send-email-groug@kaod.org> Subject: [Qemu-devel] [PULL 5/7] 9pfs: xattrcreate requires non-opened fids List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , "Aneesh Kumar K.V" , Greg Kurz The xattrcreate operation only makes sense on a freshly cloned fid actually, since any open state would be leaked because of the fid_type change. This is indeed what the linux kernel client does: fid = clone_fid(fid); [...] retval = p9_client_xattrcreate(fid, name, value_len, flags); This patch also reverts commit ff55e94d23ae since we are sure that a fid with type P9_FID_NONE doesn't have a previously allocated xattr. Signed-off-by: Greg Kurz --- hw/9pfs/9p.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 27af0072599a..547f3b558079 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3272,6 +3272,11 @@ static void coroutine_fn v9fs_xattrcreate(void *opaque) err = -EINVAL; goto out_nofid; } + if (file_fidp->fid_type != P9_FID_NONE) { + err = -EINVAL; + goto out_put_fid; + } + /* Make the file fid point to xattr */ xattr_fidp = file_fidp; xattr_fidp->fid_type = P9_FID_XATTR; @@ -3281,9 +3286,9 @@ static void coroutine_fn 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; +out_put_fid: put_fid(pdu, file_fidp); out_nofid: pdu_complete(pdu, err); -- 2.5.5