Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2109240ioo; Mon, 23 May 2022 10:14:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV86WMNfF/DPqz78v8s09R/1KsEjsN1z9RmzmQqs6uhf3MXE8NnIBF6gqgfP/A76ugXi79 X-Received: by 2002:a17:902:e2d2:b0:161:a6d8:3a0e with SMTP id l18-20020a170902e2d200b00161a6d83a0emr23027097plc.79.1653326077036; Mon, 23 May 2022 10:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326077; cv=none; d=google.com; s=arc-20160816; b=ZWUeyTQQ4Jj0KpprDQoJq/8CuHop9hSAUQ53eHdZsHUHGRcmF45LWkLBP3OWCthd3j jk82WjEDRhz+3qB77vy0K/puQvmwYUdHHchodgVINcMUk8I9pCloaM9hbYFx0OmdkOPI OJVChr98/gkzfXrsDq/PrVxWI4sl/vJbRm9ghCLEG37NVykZvgKOB3USd3u3wEM6kX+Q rbGGIVRIBzf3Y9OfbjJn4hpr7I4JTxlDdZzKdo5PzSQ48nk0O23pEUVNrdJ2LKFVF37y 56MONRgDTqi6547aJFgNAKmizcY3uAw1ICbqKQoiyXQWzfHzFcUlmbCwT+zPar7hzZ0T u9JA== 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=8X28WfgeRKKN4B4kxwue/WxrT15D5aVFzdxdYjgziEs=; b=BXAgBeIEaNZv8lJ52XtH9CJ0lR7gD2KIVA+KEcEqops1tFaIfWBDKdBTKmBuXIO8rl IA2M1IdhEHNNTYBDHnpXGPBI7DVfhwcXcRxXKX1ng6IPjrH5JfkvQSu46nRZ0T10h1HP DK6ENyCAFfHJUfiBvg/+5vYY+GxwDdnKr3nlHK39N5rnmIkRdmF9ksYXknDKoLL2bmZs pzny4H3U+c/Qx4/aJf1FMvYOSMgyfwzPGTvumDTMAtCTNKV1+sw5BhQGcbZg9q/2ejyK 9iDxepAV7cz3eQ2/7qptDf43Apy1P9mV4ZlaimxDLrjwkClCOxgUMfRlBUvuDwGWzJOV twow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zH1wukcX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q10-20020a170902f78a00b001619fbc05desi3931840pln.598.2022.05.23.10.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zH1wukcX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D82BB6E8EE; Mon, 23 May 2022 10:14:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbiEWRKK (ORCPT + 99 others); Mon, 23 May 2022 13:10:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239585AbiEWRJW (ORCPT ); Mon, 23 May 2022 13:09:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A1966C567; Mon, 23 May 2022 10:08:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 88CE3B81201; Mon, 23 May 2022 17:08:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9467C385AA; Mon, 23 May 2022 17:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325711; bh=UQmEn963an1N+8324q6nVW42Vd6cGd++y0TYi1GY9Vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zH1wukcXiv9gL3bYAdYyWmpGRVslXhf8/o1xzaD4cW9d9yKWJod51f0PgpTiYErLw ZkOnYf1w+1UluNzGqN2taO7IGIAfNwX0bqOILyINy2OC+jd9ZUG5Qf7wn3Jg++HkD3 AFt6k8T23xFWZcpCBjZOV4wRx6LmX9mt1SwrfIjI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakob Koschel , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 06/33] drbd: remove usage of list iterator variable after loop Date: Mon, 23 May 2022 19:04:55 +0200 Message-Id: <20220523165748.190396884@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165746.957506211@linuxfoundation.org> References: <20220523165746.957506211@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jakob Koschel [ Upstream commit 901aeda62efa21f2eae937bccb71b49ae531be06 ] In preparation to limit the scope of a list iterator to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. To either continue iterating from that position or skip the iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel Link: https://lore.kernel.org/r/20220331220349.885126-1-jakobkoschel@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/drbd/drbd_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index b998e3abca7a..1e02cb60b65b 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -195,7 +195,7 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr, unsigned int set_size) { struct drbd_request *r; - struct drbd_request *req = NULL; + struct drbd_request *req = NULL, *tmp = NULL; int expect_epoch = 0; int expect_size = 0; @@ -249,8 +249,11 @@ void tl_release(struct drbd_connection *connection, unsigned int barrier_nr, * to catch requests being barrier-acked "unexpectedly". * It usually should find the same req again, or some READ preceding it. */ list_for_each_entry(req, &connection->transfer_log, tl_requests) - if (req->epoch == expect_epoch) + if (req->epoch == expect_epoch) { + tmp = req; break; + } + req = list_prepare_entry(tmp, &connection->transfer_log, tl_requests); list_for_each_entry_safe_from(req, r, &connection->transfer_log, tl_requests) { if (req->epoch != expect_epoch) break; -- 2.35.1