Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1899282pxb; Thu, 16 Sep 2021 19:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIcdw9rih11TQJefIaBdELR6EBnlE38aw9E3k+58hVTJWsjHd/tWzT+OhwD6hNkgKVkBCc X-Received: by 2002:a02:6d17:: with SMTP id m23mr6646783jac.63.1631845966210; Thu, 16 Sep 2021 19:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631845966; cv=none; d=google.com; s=arc-20160816; b=cDzGZ0a2rR20TuqidSnSU3im5klkh0qE0hjN9A7cOBYxz1TzPcNzNJjjguk30KJkR2 prtrTFCmhI2nYQ1P4mZO5oLyVBadvijACerMLGHU+780+8YxZpn2mQUWDt+S44EbxzpL 3unZ2G7zYNEKCEFLM+/sQ09Gol3lhDQHjD2vb6+epvaKgacUHQnW2Vqy4ew3WeLVbitI sMnxwtzP06UfQQWKUuV37uUqoVOBrT23a1xAqdTIcLWnMpeYaM27DWjskDSh6RNd7djc QXbOal9n6WnaUUzPSW6JrpH3S5+RAPwskneRF1Ma/hO6xSZ3tXMme7xCjJmb1DnGwxmg JKYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iBmkBPf5sHKfZJmErXuuEkd1lcVtgqLc1MHj8ltC8yk=; b=qFrkR0s5cjBtCeJXw4WVu3t2IIZl1xtS0lqItteXasHtQ+0ad8jIKuBCrYUTkhjA2a pPc1fHvKQtKkUDf9eY4z9Nc/vaUGOMfqLAmVe3wOcoRxuXFQ+vDIhr+OZfI4mI3yWvKs 3W9Wfhf5jHV8qnp7GAAYBGnjVADovLKwVuseH80y8CGDIfFTyFLF1Bycm+Yr5wC5+8dI lDmz0Y2+xXq69ssScgP+CZXvf/jZjr+IPI1qU4dAXgu/KGX7Oj5Idimnng2vfmRv8SmS jew3dXNbo3GksIbk36J6sgQ1bnAUYUP5fZoDk8Dqgva9iJeCr8x6Ck6zODxOonS8LHHP 0jBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ICpdTwAM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si1267874jaj.93.2021.09.16.19.32.34; Thu, 16 Sep 2021 19:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ICpdTwAM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244056AbhIPRNP (ORCPT + 99 others); Thu, 16 Sep 2021 13:13:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:35942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349468AbhIPRFw (ORCPT ); Thu, 16 Sep 2021 13:05:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89F9161881; Thu, 16 Sep 2021 16:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810135; bh=aQ3ss94Ysz8Z2rgJ7EBicK34Av2AyGubTaj1Y/1YGx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICpdTwAMSY5MXZYYC2/D0qt0RNLoF3To0d30/WI7N7sELjrWGQCzZIz871OFlFshi G7aVfjlylzxakucTNxF/Kx7ESXxnRGasGN/n5/LvLxIqWw9pbhQ8XPbZp+q+CatFzg Xr4zBy8u3lPgnthU947CljhQHDoQ6IKAJ77TLA6M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harshvardhan Jha , Stefano Stabellini , Dominique Martinet Subject: [PATCH 5.14 022/432] 9p/xen: Fix end of loop tests for list_for_each_entry Date: Thu, 16 Sep 2021 17:56:11 +0200 Message-Id: <20210916155811.577357838@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harshvardhan Jha commit 732b33d0dbf17e9483f0b50385bf606f724f50a2 upstream. This patch addresses the following problems: - priv can never be NULL, so this part of the check is useless - if the loop ran through the whole list, priv->client is invalid and it is more appropriate and sufficient to check for the end of list_for_each_entry loop condition. Link: http://lkml.kernel.org/r/20210727000709.225032-1-harshvardhan.jha@oracle.com Signed-off-by: Harshvardhan Jha Reviewed-by: Stefano Stabellini Tested-by: Stefano Stabellini Cc: Signed-off-by: Dominique Martinet Signed-off-by: Greg Kroah-Hartman --- net/9p/trans_xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -138,7 +138,7 @@ static bool p9_xen_write_todo(struct xen static int p9_xen_request(struct p9_client *client, struct p9_req_t *p9_req) { - struct xen_9pfs_front_priv *priv = NULL; + struct xen_9pfs_front_priv *priv; RING_IDX cons, prod, masked_cons, masked_prod; unsigned long flags; u32 size = p9_req->tc.size; @@ -151,7 +151,7 @@ static int p9_xen_request(struct p9_clie break; } read_unlock(&xen_9pfs_lock); - if (!priv || priv->client != client) + if (list_entry_is_head(priv, &xen_9pfs_devs, list)) return -EINVAL; num = p9_req->tc.tag % priv->num_rings;