* [PATCH RESEND] mailbox: pcc: fix channel calculation in get_pcc_channel()
@ 2016-02-02 11:29 Alexey Klimov
2016-02-03 1:27 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Klimov @ 2016-02-02 11:29 UTC (permalink / raw)
To: rjw, linux-acpi
Cc: jassisinghbrar, sudeep.holla, ashwin.chaugule, pprakash, linux-kernel
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.
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
Signed-off-by: Alexey Klimov <alexey.klimov@arm.com>
---
drivers/mailbox/pcc.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
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];
}
/**
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] mailbox: pcc: fix channel calculation in get_pcc_channel()
2016-02-02 11:29 [PATCH RESEND] mailbox: pcc: fix channel calculation in get_pcc_channel() Alexey Klimov
@ 2016-02-03 1:27 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2016-02-03 1:27 UTC (permalink / raw)
To: Alexey Klimov
Cc: linux-acpi, jassisinghbrar, sudeep.holla, ashwin.chaugule,
pprakash, linux-kernel
On Tuesday, February 02, 2016 11:29:22 AM Alexey Klimov wrote:
> 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.
>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Acked-by: Ashwin Chaugule <ashwin.chaugule@linaro.org>
> Signed-off-by: Alexey Klimov <alexey.klimov@arm.com>
Jassi said this was applied, so I'm not taking it.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-03 1:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 11:29 [PATCH RESEND] mailbox: pcc: fix channel calculation in get_pcc_channel() Alexey Klimov
2016-02-03 1:27 ` Rafael J. Wysocki
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®