From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 10FAF22AE65 for ; Mon, 22 Jun 2026 04:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782102788; cv=none; b=kV5CiMIP0vDLSsL3jW3gVkG/0M5S258PNd/VKBlpv8tX0COF/s0u9rGNi1ZkSBJtnz5jKuMIIn10+3DmxsQSU12u0Z5TOLtvX3B2pH/ggg+w6V8y5WuWVwHlvwIKolzVphik44ev8BPAbWtu+Jou9v6u9GqovbLXATaSq1u8btk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782102788; c=relaxed/simple; bh=6DEtv6yb5D3pU4W3a42V7jIWtD557aOuwYlsmACNTn8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=vFe/z6Ei42lfKWCBLY5y9kv8nrRWriWrORpp+KWT47MQk2hRHUy4pkUGjib3h0t2opEpAeB2sg2nVNMIWGGBOAYHuR/oBoSkMdNh5b34m6bJzwuNZjGkBQxFiubHU2RjVvtM+/CBL7ZF4ZIrsH8sS5FsQccVodQdmcXUoS9UlA8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=J73Tuhvo; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="J73Tuhvo" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782102785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LqeobtkxZIczjC3bBaAr9HImKF/rei2wNFng7Y5jhs0=; b=J73TuhvoABT/umMjUMDoOw/XnTyXYEE5/YjP1mgTcrUguIUwP17QV3gx3fICXFV9IPGuNB tZniVKISrXoWEXYV+KKrhC2+YlbDYPB0T6LWAbBlw2qU+LtOv0o88xSgFb/zG5YKx/xmhz q1Jlnb4JdnpR/gCl4Scnv2bdG58HPUU= From: Kaitao Cheng To: Alexander Viro , Christian Brauner , Jan Kara Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kaitao Cheng Subject: [PATCH v3 6/7] initramfs: Use mutable list iterator Date: Mon, 22 Jun 2026 12:32:10 +0800 Message-ID: <20260622043210.32069-1-kaitao.cheng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Kaitao Cheng The safe list iterator in dir_utime() requires a temporary cursor even though the loop body only deletes and frees the current entry. The mutable iterator keeps the same removal-safe traversal semantics while hiding the internal cursor from the call site. Switch dir_utime() to list_for_each_entry_mutable() and drop the unused temporary cursor variable. No functional change is intended. Signed-off-by: Kaitao Cheng --- init/initramfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 20a18fcda48e..e226d7eb1257 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -167,8 +167,9 @@ static void __init dir_add(const char *name, size_t nlen, time64_t mtime) static void __init dir_utime(void) { - struct dir_entry *de, *tmp; - list_for_each_entry_safe(de, tmp, &dir_list, list) { + struct dir_entry *de; + + list_for_each_entry_mutable(de, &dir_list, list) { list_del(&de->list); do_utime(de->name, de->mtime); kfree(de); -- 2.43.0