lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220331214719.881886-1-jakobkoschel@gmail.com>
Date:   Thu, 31 Mar 2022 23:47:17 +0200
From:   Jakob Koschel <jakobkoschel@...il.com>
To:     Lubomir Rintel <lkundrak@...sk>
Cc:     Russell King <linux@...linux.org.uk>,
        "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
        Pali Rohár <pali@...nel.org>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Mike Rapoport <rppt@...nel.org>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        "Brian Johannesmeyer" <bjohannesmeyer@...il.com>,
        Cristiano Giuffrida <c.giuffrida@...nl>,
        "Bos, H.J." <h.j.bos@...nl>, Jakob Koschel <jakobkoschel@...il.com>
Subject: [PATCH 1/3] ARM: ioremap: remove usage of list iterator for list_add() after the loop body

In preparation to limit the scope of a list iterator to the list
traversal loop, use a dedicated pointer to point to the found element [1].

Before, the code implicitly used the head when no element was found
when using &pos->list. Since the new variable is only set if an
element was found, the list_add() is performed within the loop
and only done after the loop if it is done on the list head directly.

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Signed-off-by: Jakob Koschel <jakobkoschel@...il.com>
---
 arch/arm/mm/ioremap.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index aa08bcb72db9..417fd5ffa162 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -90,7 +90,7 @@ struct static_vm *find_static_vm_vaddr(void *vaddr)
 
 void __init add_static_vm_early(struct static_vm *svm)
 {
-	struct static_vm *curr_svm;
+	struct static_vm *curr_svm = NULL, *iter;
 	struct vm_struct *vm;
 	void *vaddr;
 
@@ -98,13 +98,17 @@ void __init add_static_vm_early(struct static_vm *svm)
 	vm_area_add_early(vm);
 	vaddr = vm->addr;
 
-	list_for_each_entry(curr_svm, &static_vmlist, list) {
-		vm = &curr_svm->vm;
+	list_for_each_entry(iter, &static_vmlist, list) {
+		vm = &iter->vm;
 
-		if (vm->addr > vaddr)
+		if (vm->addr > vaddr) {
+			curr_svm = iter;
+			list_add_tail(&svm->list, &iter->list);
 			break;
+		}
 	}
-	list_add_tail(&svm->list, &curr_svm->list);
+	if (!curr_svm)
+		list_add_tail(&svm->list, &static_vmlist);
 }
 
 int ioremap_page(unsigned long virt, unsigned long phys,

base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ