From e9c8dc8ba96b165ae72daad3b1f27823c3aee628 Mon Sep 17 00:00:00 2001 From: Alexey Klimov Date: Thu, 10 Dec 2015 17:28:37 +0000 Subject: mailbox: pcc: fix channel calculation in get_pcc_channel() This patch fixes the calculation of pcc_chan for non-zero id. After the compiler ignores the (unsigned long) cast the pcc_mbox_channels pointer is type-cast and then the type-cast offset is added which results in address outside of the range leading to the kernel crashing. We might add braces and make it: pcc_chan = (struct mbox_chan *) ((unsigned long) pcc_mbox_channels + (id * sizeof(*pcc_chan))); but let's go with array approach here and use id as index. Tested on Juno board. Signed-off-by: Alexey Klimov Acked-by: Sudeep Holla Acked-by: Ashwin Chaugule Signed-off-by: Jassi Brar diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 45d85ae..8f779a1 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -81,16 +81,10 @@ static struct mbox_controller pcc_mbox_ctrl = {}; */ static struct mbox_chan *get_pcc_channel(int id) { - struct mbox_chan *pcc_chan; - if (id < 0 || id > pcc_mbox_ctrl.num_chans) return ERR_PTR(-ENOENT); - pcc_chan = (struct mbox_chan *) - (unsigned long) pcc_mbox_channels + - (id * sizeof(*pcc_chan)); - - return pcc_chan; + return &pcc_mbox_channels[id]; } /** -- cgit v0.10.2 From 65d3b04a814679a31fe4d5edd19d89dd5b94fd40 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 25 Jan 2016 23:24:09 +0100 Subject: mailbox: Fix dependencies for !HAS_IOMEM archs Not every arch has io memory. So, unbreak the build by fixing the dependencies. Signed-off-by: Richard Weinberger Signed-off-by: Jassi Brar diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 546d05f..b2bbe86 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -81,6 +81,7 @@ config STI_MBOX config MAILBOX_TEST tristate "Mailbox Test Client" depends on OF + depends on HAS_IOMEM help Test client to help with testing new Controller driver implementations. -- cgit v0.10.2