From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758226AbcISG2e (ORCPT ); Mon, 19 Sep 2016 02:28:34 -0400 Received: from atlantic540.startdedicated.de ([188.138.9.77]:60317 "EHLO atlantic540.startdedicated.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754071AbcISG2Y (ORCPT ); Mon, 19 Sep 2016 02:28:24 -0400 From: Daniel Wagner To: linux-cris-kernel@axis.com Cc: Jesper Nilsson , Mikael Starvik , Paul Gortmaker , linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH 1/2] cris: don't compare incompatible pointer type Date: Mon, 19 Sep 2016 08:27:56 +0200 Message-Id: <1474266477-26090-2-git-send-email-wagi@monom.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474266477-26090-1-git-send-email-wagi@monom.org> References: <1474266477-26090-1-git-send-email-wagi@monom.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Wagner 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 Cc: Mikael Starvik Cc: Jesper Nilsson Cc: linux-cris-kernel@axis.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