* [PATCH 2/2] ic3: master: off by one in mode_show()
@ 2018-11-23 7:15 Dan Carpenter
2018-11-26 8:46 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-11-23 7:15 UTC (permalink / raw)
To: Boris Brezillon; +Cc: linux-kernel, kernel-janitors
This should be >= ARRAY_SIZE() to avoid reading one element beyond the
end of the array.
Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/i3c/master.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index bda4b9613e53..c39f89d2deba 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -475,7 +475,7 @@ static ssize_t mode_show(struct device *dev,
i3c_bus_normaluse_lock(i3cbus);
if (i3cbus->mode < 0 ||
- i3cbus->mode > ARRAY_SIZE(i3c_bus_mode_strings) ||
+ i3cbus->mode >= ARRAY_SIZE(i3c_bus_mode_strings) ||
!i3c_bus_mode_strings[i3cbus->mode])
ret = sprintf(buf, "unknown\n");
else
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] ic3: master: off by one in mode_show()
2018-11-23 7:15 [PATCH 2/2] ic3: master: off by one in mode_show() Dan Carpenter
@ 2018-11-26 8:46 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2018-11-26 8:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kernel, kernel-janitors
On Fri, 23 Nov 2018 10:15:05 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This should be >= ARRAY_SIZE() to avoid reading one element beyond the
> end of the array.
>
> Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Queued to i3c/next.
Thanks,
Boris
> ---
> drivers/i3c/master.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index bda4b9613e53..c39f89d2deba 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -475,7 +475,7 @@ static ssize_t mode_show(struct device *dev,
>
> i3c_bus_normaluse_lock(i3cbus);
> if (i3cbus->mode < 0 ||
> - i3cbus->mode > ARRAY_SIZE(i3c_bus_mode_strings) ||
> + i3cbus->mode >= ARRAY_SIZE(i3c_bus_mode_strings) ||
> !i3c_bus_mode_strings[i3cbus->mode])
> ret = sprintf(buf, "unknown\n");
> else
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-26 8:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-23 7:15 [PATCH 2/2] ic3: master: off by one in mode_show() Dan Carpenter
2018-11-26 8:46 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).