All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cros_ec: fix nul-termination for firmware build info
@ 2017-12-04 14:49 Arnd Bergmann
  2017-12-16  5:08 ` Benson Leung
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-12-04 14:49 UTC (permalink / raw)
  To: Benson Leung, Olof Johansson; +Cc: Arnd Bergmann, linux-kernel

As gcc-8 reports, we zero out the wrong byte:

drivers/platform/chrome/cros_ec_sysfs.c: In function 'show_ec_version':
drivers/platform/chrome/cros_ec_sysfs.c:190:12: error: array subscript 4294967295 is above array bounds of 'uint8_t[]' [-Werror=array-bounds]

This changes the code back to what it did before changing to a
zero-length array structure.

Fixes: a841178445bb ("mfd: cros_ec: Use a zero-length array for command data")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/platform/chrome/cros_ec_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index f3baf9973989..24f1630a8b3f 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -187,7 +187,7 @@ static ssize_t show_ec_version(struct device *dev,
 		count += scnprintf(buf + count, PAGE_SIZE - count,
 				   "Build info:    EC error %d\n", msg->result);
 	else {
-		msg->data[sizeof(msg->data) - 1] = '\0';
+		msg->data[EC_HOST_PARAM_SIZE - 1] = '\0';
 		count += scnprintf(buf + count, PAGE_SIZE - count,
 				   "Build info:    %s\n", msg->data);
 	}
-- 
2.9.0

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

* Re: [PATCH] cros_ec: fix nul-termination for firmware build info
  2017-12-04 14:49 [PATCH] cros_ec: fix nul-termination for firmware build info Arnd Bergmann
@ 2017-12-16  5:08 ` Benson Leung
  0 siblings, 0 replies; 2+ messages in thread
From: Benson Leung @ 2017-12-16  5:08 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Benson Leung, Olof Johansson, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 753 bytes --]

Hi Arnd,

On Mon, Dec 04, 2017 at 03:49:48PM +0100, Arnd Bergmann wrote:
> As gcc-8 reports, we zero out the wrong byte:
> 
> drivers/platform/chrome/cros_ec_sysfs.c: In function 'show_ec_version':
> drivers/platform/chrome/cros_ec_sysfs.c:190:12: error: array subscript 4294967295 is above array bounds of 'uint8_t[]' [-Werror=array-bounds]
> 
> This changes the code back to what it did before changing to a
> zero-length array structure.
> 
> Fixes: a841178445bb ("mfd: cros_ec: Use a zero-length array for command data")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied. Thanks!

Benson

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2017-12-16  5:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04 14:49 [PATCH] cros_ec: fix nul-termination for firmware build info Arnd Bergmann
2017-12-16  5:08 ` Benson Leung

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.