From: Daniel Wagner <wagi@monom.org>
To: linux-cris-kernel@axis.com
Cc: Jesper Nilsson <jesper.nilsson@axis.com>,
Mikael Starvik <starvik@axis.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
linux-kernel@vger.kernel.org,
Daniel Wagner <daniel.wagner@bmw-carit.de>
Subject: [PATCH 1/2] cris: don't compare incompatible pointer type
Date: Mon, 19 Sep 2016 08:27:56 +0200 [thread overview]
Message-ID: <1474266477-26090-2-git-send-email-wagi@monom.org> (raw)
In-Reply-To: <1474266477-26090-1-git-send-email-wagi@monom.org>
From: Daniel Wagner <daniel.wagner@bmw-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@intel.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
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
next prev parent reply other threads:[~2016-09-19 6:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-19 6:27 [PATCH 0/2] cris: fix a couple of incompatible pointer types Daniel Wagner
2016-09-19 6:27 ` Daniel Wagner [this message]
2016-09-19 6:27 ` [PATCH 2/2] cris: use correct device_init() function signature Daniel Wagner
2016-09-19 6:59 ` [PATCH 0/2] cris: fix a couple of incompatible pointer types Niklas Cassel
2016-09-19 7:08 ` Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1474266477-26090-2-git-send-email-wagi@monom.org \
--to=wagi@monom.org \
--cc=daniel.wagner@bmw-carit.de \
--cc=jesper.nilsson@axis.com \
--cc=linux-cris-kernel@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=starvik@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®