Validate the framebuffer size from the firmware against the
limitations of struct drm_display_mode. The type only stores sizes
in 16-bit fields. Fail probing on errors.

Signed-off-by: Thomas Zimmermann <[email protected]>
Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
Cc: <[email protected]> # v5.14+
---
 drivers/gpu/drm/sysfb/simpledrm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sysfb/simpledrm.c 
b/drivers/gpu/drm/sysfb/simpledrm.c
index fc168920f2c6..03bd19fadccd 100644
--- a/drivers/gpu/drm/sysfb/simpledrm.c
+++ b/drivers/gpu/drm/sysfb/simpledrm.c
@@ -88,14 +88,14 @@ static int
 simplefb_get_width_pd(struct drm_device *dev,
                      const struct simplefb_platform_data *pd)
 {
-       return simplefb_get_validated_int0(dev, "width", pd->width);
+       return drm_sysfb_get_validated_int0(dev, "width", pd->width, U16_MAX);
 }
 
 static int
 simplefb_get_height_pd(struct drm_device *dev,
                       const struct simplefb_platform_data *pd)
 {
-       return simplefb_get_validated_int0(dev, "height", pd->height);
+       return drm_sysfb_get_validated_int0(dev, "height", pd->height, U16_MAX);
 }
 
 static int
@@ -144,7 +144,7 @@ simplefb_get_width_of(struct drm_device *dev, struct 
device_node *of_node)
 
        if (ret)
                return ret;
-       return simplefb_get_validated_int0(dev, "width", width);
+       return drm_sysfb_get_validated_int0(dev, "width", width, U16_MAX);
 }
 
 static int
@@ -155,7 +155,7 @@ simplefb_get_height_of(struct drm_device *dev, struct 
device_node *of_node)
 
        if (ret)
                return ret;
-       return simplefb_get_validated_int0(dev, "height", height);
+       return drm_sysfb_get_validated_int0(dev, "height", height, U16_MAX);
 }
 
 static int
-- 
2.54.0

Reply via email to