drm/sysfb: simpledrm: Improve framebuffer-size validation

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.

v2:
- remove unused function simplefb_get_validated_int0() (Sashiko)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Fixes: 11e8f5fd22 ("drm: Add simpledrm driver")
Cc: <stable@vger.kernel.org> # v5.14+
Fixes: 11e8f5fd22 ("drm: Add simpledrm driver")
Link: https://patch.msgid.link/20260625094509.157581-2-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann 2026-06-25 11:39:33 +02:00
parent cc79eaf8ee
commit 03f1a3545b

View File

@ -48,13 +48,6 @@ simplefb_get_validated_int(struct drm_device *dev, const char *name,
return drm_sysfb_get_validated_int(dev, name, value, INT_MAX);
}
static int
simplefb_get_validated_int0(struct drm_device *dev, const char *name,
uint32_t value)
{
return drm_sysfb_get_validated_int0(dev, name, value, INT_MAX);
}
static const struct drm_format_info *
simplefb_get_validated_format(struct drm_device *dev, const char *format_name)
{
@ -88,14 +81,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 +137,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 +148,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