From nobody Mon May 13 01:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1621188577; cv=none; d=zohomail.com; s=zohoarc; b=Y4tsGy6MYRyzk2Q9mgF75X5nl0Ds33scZY8EsjjrkBNl9QeORyjiTU2D52cd5IVVehlEZ8Ctzd/GgxPWXrVlzQZCKN0Nh9X9pkttt8lAvYa6HjmO0e4hw1rK3huA9cFFfYJVmTVDTmQcUtJlwNxkAcCc6niN9VeAlQK/Lh25sW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621188577; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=G79lVmtym+xutLubi7aAXG7xmx7rth7ox5YVCmYh3Cg=; b=XYt/lu4zTrDxyIu7vCelDOt6Gfd9JSHtU/xZOKq6lQPUc+4NKLvJtAoDKB9biCSZUKPtMTpJla3Smoo6xA6Nug2mjywu2nAzpLO/pDt6ZS6IKKQ/Z+MJQAQpWrhXbte08XB+UmTssB8FPGJlOrQ28ilaPi6TLBVpusaY3V2D7ZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621188577626520.3884100410424; Sun, 16 May 2021 11:09:37 -0700 (PDT) Received: from localhost ([::1]:33016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liLCp-0005fs-TU for importer@patchew.org; Sun, 16 May 2021 14:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0eec3beb82ef137e20cf6f5ac07b0049cd314463@lizzy.crudebyte.com>) id 1liLBV-0004ym-KY for qemu-devel@nongnu.org; Sun, 16 May 2021 14:08:13 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39219) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <0eec3beb82ef137e20cf6f5ac07b0049cd314463@lizzy.crudebyte.com>) id 1liLBS-0002Bd-JJ for qemu-devel@nongnu.org; Sun, 16 May 2021 14:08:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Message-Id:Cc:To:Subject:Date:From:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Content-ID: Content-Description; bh=G79lVmtym+xutLubi7aAXG7xmx7rth7ox5YVCmYh3Cg=; b=k//JY EW1ercYu3dxYDWMnyVW8KFBq86QtxEIC4W31lAUTQLAe4A54Ndz9iFXxqKS+3bjSE+hTtL8esS0pg ESTUzNkUxJjPsziwQRzKGn+ybviaks2VsNSNdnuU3tyB3llSAmtz4TkTcPdeB2/dKMLRlCZKW+YLd FmztyZfXmnNOqNd8iGuJhg/XVryGgNNviPfB/AbP1TiO6x8MmbPfWnG4ksHTlCtO6E1ZVHZmvaPM5 y1slYbWxkyRWM03d82AKjjrT0favt82Ry0udbQTxPpBwa7GUpX1jxUrYAM52IL4z9SRjzmWKdssHu DdEmZN/Z+Cb4pMdekPjjPcDgf/Wng==; From: Christian Schoenebeck Date: Sun, 16 May 2021 17:55:34 +0200 Subject: [PATCH] 9pfs: simplify v9fs_walk() To: qemu-devel@nongnu.org Cc: Greg Kurz Message-Id: Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=0eec3beb82ef137e20cf6f5ac07b0049cd314463@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is only one comparison between nwnames and P9_MAXWELEM required. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 0fa776af09..89aa07db78 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1739,7 +1739,11 @@ static void coroutine_fn v9fs_walk(void *opaque) =20 trace_v9fs_walk(pdu->tag, pdu->id, fid, newfid, nwnames); =20 - if (nwnames && nwnames <=3D P9_MAXWELEM) { + if (nwnames > P9_MAXWELEM) { + err =3D -EINVAL; + goto out_nofid; + } + if (nwnames) { wnames =3D g_new0(V9fsString, nwnames); qids =3D g_new0(V9fsQID, nwnames); for (i =3D 0; i < nwnames; i++) { @@ -1753,9 +1757,6 @@ static void coroutine_fn v9fs_walk(void *opaque) } offset +=3D err; } - } else if (nwnames > P9_MAXWELEM) { - err =3D -EINVAL; - goto out_nofid; } fidp =3D get_fid(pdu, fid); if (fidp =3D=3D NULL) { --=20 2.20.1