* [PATCH v3] firmware: socfpga: Fix a bug in fpgamgr_program_write_buf()
@ 2015-04-21 23:25 Andrey Smirnov
2015-04-23 5:58 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2015-04-21 23:25 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
Fix a bug in fpgamgr_program_write_buf() where .rbf file whose length
is not a multiple of 4 would cause an integer overflow which would
result in infinite loop.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/firmware/socfpga.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/socfpga.c b/drivers/firmware/socfpga.c
index a5dc607..14a7a14 100644
--- a/drivers/firmware/socfpga.c
+++ b/drivers/firmware/socfpga.c
@@ -324,13 +324,27 @@ static int fpgamgr_program_write_buf(struct firmware_handler *fh, const void *bu
const uint32_t *buf32 = buf;
/* write to FPGA Manager AXI data */
- while (size) {
+ while (size >= sizeof(uint32_t)) {
writel(*buf32, mgr->regs_data);
readl(mgr->regs + FPGAMGRREGS_MON_GPIO_EXT_PORTA_ADDRESS);
buf32++;
size -= sizeof(uint32_t);
}
+ if (size) {
+ const uint8_t *buf8 = (const uint8_t *)buf32;
+ uint32_t word = 0;
+
+ while (size--) {
+ word |= *buf8;
+ word <<= 8;
+ buf8++;
+ }
+
+ writel(word, mgr->regs_data);
+ readl(mgr->regs + FPGAMGRREGS_MON_GPIO_EXT_PORTA_ADDRESS);
+ }
+
return 0;
}
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] firmware: socfpga: Fix a bug in fpgamgr_program_write_buf()
2015-04-21 23:25 [PATCH v3] firmware: socfpga: Fix a bug in fpgamgr_program_write_buf() Andrey Smirnov
@ 2015-04-23 5:58 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-04-23 5:58 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
On Tue, Apr 21, 2015 at 04:25:02PM -0700, Andrey Smirnov wrote:
> Fix a bug in fpgamgr_program_write_buf() where .rbf file whose length
> is not a multiple of 4 would cause an integer overflow which would
> result in infinite loop.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> drivers/firmware/socfpga.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-23 5:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 23:25 [PATCH v3] firmware: socfpga: Fix a bug in fpgamgr_program_write_buf() Andrey Smirnov
2015-04-23 5:58 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox