memory: brcmstb_dpfe: fix array index out of bounds
authorMarkus Mayer <mmayer@broadcom.com>
Sat, 22 Aug 2020 20:50:00 +0000 (13:50 -0700)
committerKrzysztof Kozlowski <krzk@kernel.org>
Sat, 22 Aug 2020 20:53:28 +0000 (22:53 +0200)
commitf42ae4bbf94c15aa720afb9d176ecbfe140d792e
tree2c56fcfe66fbd954c81a5b6371eb149c6b7a5c2a
parent4da1edcf8f226d53c02c6b0e3077d581115b30d0
memory: brcmstb_dpfe: fix array index out of bounds

We would overrun the error_text array if we hit a TIMEOUT condition,
because we were using the error code "ETIMEDOUT" (which is 110) as an
array index.

We fix the problem by correcting the array index and by providing a
function to retrieve error messages rather than accessing the array
directly. The function includes a bounds check that prevents the array
from being overrun.

Link: https://lore.kernel.org/linux-arm-kernel/38d00022-730c-948a-917c-d86382df8cb9@canonical.com/
Link: https://lore.kernel.org/r/20200822205000.15841-1-mmayer@broadcom.com
Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
drivers/memory/brcmstb_dpfe.c