summaryrefslogtreecommitdiffstats
path: root/drivers/mailbox/pcc.c
diff options
context:
space:
mode:
authorAlexey Klimov <alexey.klimov@arm.com>2015-12-10 18:28:37 +0100
committerJassi Brar <jaswinder.singh@linaro.org>2016-02-02 12:09:13 +0100
commite9c8dc8ba96b165ae72daad3b1f27823c3aee628 (patch)
treefa2a6b0a43b5c56c1faf09f1068acc5cbc0457b0 /drivers/mailbox/pcc.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (diff)
downloadlinux-e9c8dc8ba96b165ae72daad3b1f27823c3aee628.tar.xz
linux-e9c8dc8ba96b165ae72daad3b1f27823c3aee628.zip
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 <alexey.klimov@arm.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Diffstat (limited to 'drivers/mailbox/pcc.c')
-rw-r--r--drivers/mailbox/pcc.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 45d85aea9955..8f779a1ec99c 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];
}
/**