[PATCH 1/2] cris: don't compare incompatible pointer type
From: Daniel Wagner
Date: Mon Sep 19 2016 - 02:28:41 EST
From: Daniel Wagner <daniel.wagner@xxxxxxxxxxxx>
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@xxxxxxxxx>
Cc: Mikael Starvik <starvik@xxxxxxxx>
Cc: Jesper Nilsson <jesper.nilsson@xxxxxxxx>
Cc: linux-cris-kernel@xxxxxxxx
---
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