All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command
@ 2016-09-12 19:57 Moritz Fischer
  2016-09-23  4:15 ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Moritz Fischer @ 2016-09-12 19:57 UTC (permalink / raw)
  To: u-boot

This commit fixes an issue where data is written to an
invalid memory location.
The issue has been introduced in commit
(88364387 cros: add cros_ec_driver)

Cc: Simon Glass <sjg@chromium.org>
Cc: u-boot at lists.denx.de
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
---
Changes from v1:
 - Fixed accidential change of command version
 - Removed added whitespace
---
 drivers/misc/cros_ec.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 44b4f59..06a7dcc 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -760,15 +760,24 @@ int cros_ec_flash_erase(struct cros_ec_dev *dev, uint32_t offset, uint32_t size)
 static int cros_ec_flash_write_block(struct cros_ec_dev *dev,
 		const uint8_t *data, uint32_t offset, uint32_t size)
 {
-	struct ec_params_flash_write p;
+	struct ec_params_flash_write *p;
+	int ret;
 
-	p.offset = offset;
-	p.size = size;
-	assert(data && p.size <= EC_FLASH_WRITE_VER0_SIZE);
-	memcpy(&p + 1, data, p.size);
+	p = malloc(sizeof(*p) + size);
+	if (!p)
+		return -ENOMEM;
+
+	p->offset = offset;
+	p->size = size;
+	assert(data && p->size <= EC_FLASH_WRITE_VER0_SIZE);
+	memcpy(p + 1, data, p->size);
 
-	return ec_command_inptr(dev, EC_CMD_FLASH_WRITE, 0,
-			  &p, sizeof(p), NULL, 0) >= 0 ? 0 : -1;
+	ret = ec_command_inptr(dev, EC_CMD_FLASH_WRITE, 0,
+			  p, sizeof(*p) + size, NULL, 0) >= 0 ? 0 : -1;
+
+	free(p);
+
+	return ret;
 }
 
 /**
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command
  2016-09-12 19:57 [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command Moritz Fischer
@ 2016-09-23  4:15 ` Simon Glass
  2016-10-02  0:34   ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2016-09-23  4:15 UTC (permalink / raw)
  To: u-boot

On 12 September 2016 at 13:57, Moritz Fischer <moritz.fischer@ettus.com> wrote:
> This commit fixes an issue where data is written to an
> invalid memory location.
> The issue has been introduced in commit
> (88364387 cros: add cros_ec_driver)
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: u-boot at lists.denx.de
> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
> ---
> Changes from v1:
>  - Fixed accidential change of command version
>  - Removed added whitespace
> ---
>  drivers/misc/cros_ec.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command
  2016-09-23  4:15 ` Simon Glass
@ 2016-10-02  0:34   ` Simon Glass
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2016-10-02  0:34 UTC (permalink / raw)
  To: u-boot

On 22 September 2016 at 22:15, Simon Glass <sjg@chromium.org> wrote:
> On 12 September 2016 at 13:57, Moritz Fischer <moritz.fischer@ettus.com> wrote:
>> This commit fixes an issue where data is written to an
>> invalid memory location.
>> The issue has been introduced in commit
>> (88364387 cros: add cros_ec_driver)
>>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: u-boot at lists.denx.de
>> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
>> ---
>> Changes from v1:
>>  - Fixed accidential change of command version
>>  - Removed added whitespace
>> ---
>>  drivers/misc/cros_ec.c | 23 ++++++++++++++++-------
>>  1 file changed, 16 insertions(+), 7 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-02  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 19:57 [U-Boot] [PATCH v2] cros_ec: Fix issue with cros_ec_flash_write command Moritz Fischer
2016-09-23  4:15 ` Simon Glass
2016-10-02  0:34   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.