From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C7731ED4D for ; Tue, 25 Jul 2023 11:41:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F127C433C8; Tue, 25 Jul 2023 11:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690285300; bh=zaCEC6wOE3N+0sktKsE6ChVyr8tzsUio+Cw2td0aNIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4Tn1RVXthBaJyE/lQ5JBruDWMHDjvWdAe21dQRNA+a6DZ+U50BraUX7nUsaLCM3p qRWtDmMQA7nA+auyBo7B+KzjMfJprLKx2PJ2CZilckXUVeZOh8vWAviuEO84GI8wnP hBjubDGrjRaBRxJ4C1DW9MOUx+kjdK14W2oLvj6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.4 125/313] w1: fix loop in w1_fini() Date: Tue, 25 Jul 2023 12:44:38 +0200 Message-ID: <20230725104526.423117064@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104521.167250627@linuxfoundation.org> References: <20230725104521.167250627@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Dan Carpenter [ Upstream commit 83f3fcf96fcc7e5405b37d9424c7ef26bfa203f8 ] The __w1_remove_master_device() function calls: list_del(&dev->w1_master_entry); So presumably this can cause an endless loop. Fixes: 7785925dd8e0 ("[PATCH] w1: cleanups.") Signed-off-by: Dan Carpenter Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/w1/w1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 2a7970a10533e..e08f40c9d54c9 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -1228,10 +1228,10 @@ static int __init w1_init(void) static void __exit w1_fini(void) { - struct w1_master *dev; + struct w1_master *dev, *n; /* Set netlink removal messages and some cleanup */ - list_for_each_entry(dev, &w1_masters, w1_master_entry) + list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) __w1_remove_master_device(dev); w1_fini_netlink(); -- 2.39.2