Commit 130cdec4 authored by Dan Carpenter's avatar Dan Carpenter Committed by Maxime Ripard

drm/vc4: hdmi: Fix off by ones in vc4_hdmi_read/write()

The variant->registers[] has ->num_registers elements so the >
comparison needs to be changes to >= to prevent an out of bounds
access.

Fixes: 311e305f ("drm/vc4: hdmi: Implement a register layout abstraction")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200910100748.GA79916@mwanda
parent 6a8a58ac
...@@ -398,7 +398,7 @@ static inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi, ...@@ -398,7 +398,7 @@ static inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi,
const struct vc4_hdmi_variant *variant = hdmi->variant; const struct vc4_hdmi_variant *variant = hdmi->variant;
void __iomem *base; void __iomem *base;
if (reg > variant->num_registers) { if (reg >= variant->num_registers) {
dev_warn(&hdmi->pdev->dev, dev_warn(&hdmi->pdev->dev,
"Invalid register ID %u\n", reg); "Invalid register ID %u\n", reg);
return 0; return 0;
...@@ -424,7 +424,7 @@ static inline void vc4_hdmi_write(struct vc4_hdmi *hdmi, ...@@ -424,7 +424,7 @@ static inline void vc4_hdmi_write(struct vc4_hdmi *hdmi,
const struct vc4_hdmi_variant *variant = hdmi->variant; const struct vc4_hdmi_variant *variant = hdmi->variant;
void __iomem *base; void __iomem *base;
if (reg > variant->num_registers) { if (reg >= variant->num_registers) {
dev_warn(&hdmi->pdev->dev, dev_warn(&hdmi->pdev->dev,
"Invalid register ID %u\n", reg); "Invalid register ID %u\n", reg);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment