Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565623lkm; Mon, 20 Sep 2021 18:52:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBuXK0UPA8lobEgP/ellvCC/4f8lBbCc1LVMU0mbTqSPd08/IDdaZRXk9F3107JRNNhx6z X-Received: by 2002:a6b:7214:: with SMTP id n20mr632874ioc.194.1632188996372; Mon, 20 Sep 2021 18:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188996; cv=none; d=google.com; s=arc-20160816; b=Zjp/sfgbor+wXhKgrbB6F+Ww0b6g6KMAwdbR8RCZlMotK+v3s8BuWdqkzYvh7e0jFJ 7IheadJTsRXx0sOGw+3q3CuITDRmV8BLx3RWTBxH9raDE5f+B0FhTrJqQY5V9gfhKDjX HQBXG3zwqp3a5NSBpAJ7j84VbJqZijp7JYh8Vn/PI264DxGhJpSAvrJUeZzDT/7OehkS YJKlwoXjjPdyBm88Ws39p87jMYz6j1sNUphn9W47ebs9mn7dB8ZVr8g56hvOnlEpBBf1 GdsfSNWF1cDvovL2R8GkG8qj6CZB0m2MQmxCbY8AbwNWyUC7uGmYCsLkcX44RG2ZmbzQ RRYA== 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=ag4voAPHVi9dUyPiToABvdz7V1drJm0Fbv6WNYAgSQ2Vg54giEm//AUnvX7O60cK3B rA3zEKTOqmm3JNm1y7pMdWEq16HkF9jgIDZvsn5xkk6jI6b7RXA2OctaFGCj/T0sB2VI PrsmqKZZgZewkiZAeItk31o1fW6Cgv6El05r5aGg3UTAjP9LepLkDJlXf3cHeDSFUcF5 ztu0H5mcbpfcyhGskcryq//lT6C63wmPtYX/8cHQqE+InVbLyhGZzZc6lX1J+XQ95YR9 Z2HCJ6ih5BIhG+2HAP5OCIi+zzgj8otyQBQxH1oDtrpXkyLssIQvP9v2raFncX/7HKIf B4ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jTxl1rDc; 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 e46si13135691jaf.50.2021.09.20.18.49.45; Mon, 20 Sep 2021 18:49:56 -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=jTxl1rDc; 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 S1353507AbhITRpH (ORCPT + 99 others); Mon, 20 Sep 2021 13:45:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:47394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348934AbhITRmf (ORCPT ); Mon, 20 Sep 2021 13:42:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C91E161B67; Mon, 20 Sep 2021 17:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157733; bh=aQ3ss94Ysz8Z2rgJ7EBicK34Av2AyGubTaj1Y/1YGx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTxl1rDcpTVT9d2ifPXn9z6X+S+BXEytGyj5m7LRXjtTDi+0ssvcjwCS0S9eTCEiM NQvyGgzXYdfJ7u7XB0PXvIBoP2tX4T6nwJzRCNPppr7/QOa0rO4mInLZWiqOgxrymu 3rxSY8fFj7H1at62+p6XbJjfj9QqHAYF9X4TwVzQ= 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 4.19 126/293] 9p/xen: Fix end of loop tests for list_for_each_entry Date: Mon, 20 Sep 2021 18:41:28 +0200 Message-Id: <20210920163937.570612652@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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;