Nico Huber has submitted this change and it was merged. ( https://review.coreboot.org/c/flashrom/+/30051 )
Change subject: dediprog: Fix small, unaligned reads
......................................................................
dediprog: Fix small, unaligned reads
This never was a use case until now but the `--fmap` code makes it
obvious: Unaligned reads that were smaller than the `chunksize` here,
were extended without considering the length of the buffer read into.
With that fixed we run into the next problem: dediprog_spi_bulk_read()
shouldn't report an error when an empty read is unaligned.
Change-Id: Ie12b62499ebfdb467d5126c00d327c76077ddead
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
Reviewed-on: https://review.coreboot.org/c/30051
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org>
Reviewed-by: David Hendricks <david.hendricks(a)gmail.com>
---
M dediprog.c
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
build bot (Jenkins): Verified
David Hendricks: Looks good to me, approved
diff --git a/dediprog.c b/dediprog.c
index 58f1d43..72818ea 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -412,15 +412,15 @@
struct libusb_transfer *transfers[DEDIPROG_ASYNC_TRANSFERS] = { NULL, };
struct libusb_transfer *transfer;
+ if (len == 0)
+ return 0;
+
if ((start % chunksize) || (len % chunksize)) {
msg_perr("%s: Unaligned start=%i, len=%i! Please report a bug at flashrom(a)flashrom.org\n",
__func__, start, len);
return 1;
}
- if (len == 0)
- return 0;
-
int command_packet_size;
switch (protocol()) {
case PROTOCOL_V1:
@@ -504,7 +504,7 @@
int ret;
/* chunksize must be 512, other sizes will NOT work at all. */
const unsigned int chunksize = 0x200;
- unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
+ unsigned int residue = start % chunksize ? min(len, chunksize - start % chunksize) : 0;
unsigned int bulklen;
dediprog_set_leds(LED_BUSY);
--
To view, visit https://review.coreboot.org/c/flashrom/+/30051
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie12b62499ebfdb467d5126c00d327c76077ddead
Gerrit-Change-Number: 30051
Gerrit-PatchSet: 2
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-MessageType: merged
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/30051
Change subject: dediprog: Fix small, unaligned reads
......................................................................
dediprog: Fix small, unaligned reads
This never was a use case until now but the `--fmap` code makes it
obvious: Unaligned reads that were smaller than the `chunksize` here,
were extended without considering the length of the buffer read into.
With that fixed we run into the next problem: dediprog_spi_bulk_read()
shouldn't report an error when an empty read is unaligned.
Change-Id: Ie12b62499ebfdb467d5126c00d327c76077ddead
Signed-off-by: Nico Huber <nico.huber(a)secunet.com>
---
M dediprog.c
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/51/30051/1
diff --git a/dediprog.c b/dediprog.c
index 58f1d43..72818ea 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -412,15 +412,15 @@
struct libusb_transfer *transfers[DEDIPROG_ASYNC_TRANSFERS] = { NULL, };
struct libusb_transfer *transfer;
+ if (len == 0)
+ return 0;
+
if ((start % chunksize) || (len % chunksize)) {
msg_perr("%s: Unaligned start=%i, len=%i! Please report a bug at flashrom(a)flashrom.org\n",
__func__, start, len);
return 1;
}
- if (len == 0)
- return 0;
-
int command_packet_size;
switch (protocol()) {
case PROTOCOL_V1:
@@ -504,7 +504,7 @@
int ret;
/* chunksize must be 512, other sizes will NOT work at all. */
const unsigned int chunksize = 0x200;
- unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
+ unsigned int residue = start % chunksize ? min(len, chunksize - start % chunksize) : 0;
unsigned int bulklen;
dediprog_set_leds(LED_BUSY);
--
To view, visit https://review.coreboot.org/c/flashrom/+/30051
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie12b62499ebfdb467d5126c00d327c76077ddead
Gerrit-Change-Number: 30051
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange