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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474266477-26090-2-git-send-email-wagi@monom.org>
Date:   Mon, 19 Sep 2016 08:27:56 +0200
From:   Daniel Wagner <wagi@...om.org>
To:     linux-cris-kernel@...s.com
Cc:     Jesper Nilsson <jesper.nilsson@...s.com>,
        Mikael Starvik <starvik@...s.com>,
        Paul Gortmaker <paul.gortmaker@...driver.com>,
        linux-kernel@...r.kernel.org,
        Daniel Wagner <daniel.wagner@...-carit.de>
Subject: [PATCH 1/2] cris: don't compare incompatible pointer type

From: Daniel Wagner <daniel.wagner@...-carit.de>

intmem_allocaionts is list head. Comparing the list head with prev and
next works so far because the entry was placed at the beginning of
struct intmem_allocation. Let's use list_entry to recover the correct
pointer and which makes this code slightly more robust.

Newer gcc version are checking the pointer types and through an error if
they don't match.

Reported-by: kbuild test robot <fengguang.wu@...el.com>
Cc: Mikael Starvik <starvik@...s.com>
Cc: Jesper Nilsson <jesper.nilsson@...s.com>
Cc: linux-cris-kernel@...s.com
---
 arch/cris/arch-v32/mm/intmem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index 9ef5609..cfe393e 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -93,6 +93,7 @@ void* crisv32_intmem_alloc(unsigned size, unsigned align)
 
 void crisv32_intmem_free(void* addr)
 {
+	struct intmem_allocation* intmem_head;
 	struct intmem_allocation* allocation;
 	struct intmem_allocation* tmp;
 
@@ -102,6 +103,8 @@ void crisv32_intmem_free(void* addr)
 	preempt_disable();
 	crisv32_intmem_init();
 
+	intmem_head = list_entry(&intmem_allocations,
+				 struct intmem_allocation, entry);
 	list_for_each_entry_safe(allocation, tmp, &intmem_allocations, entry) {
 		if (allocation->offset == (int)(addr - intmem_virtual)) {
 			struct intmem_allocation *prev =
@@ -113,14 +116,14 @@ void crisv32_intmem_free(void* addr)
 
 			allocation->status = STATUS_FREE;
 			/* Join with prev and/or next if also free */
-			if ((prev != &intmem_allocations) &&
+			if ((prev != intmem_head) &&
 					(prev->status == STATUS_FREE)) {
 				prev->size += allocation->size;
 				list_del(&allocation->entry);
 				kfree(allocation);
 				allocation = prev;
 			}
-			if ((next != &intmem_allocations) &&
+			if ((next != intmem_head) &&
 					(next->status == STATUS_FREE)) {
 				allocation->size += next->size;
 				list_del(&next->entry);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ