]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fbdev: omapfb: Add 'plane' value check
authorLeonid Arapov <arapovl839@gmail.com>
Tue, 18 Mar 2025 21:19:52 +0000 (21:19 +0000)
committerHelge Deller <deller@gmx.de>
Wed, 26 Mar 2025 21:39:21 +0000 (22:39 +0100)
Function dispc_ovl_setup is not intended to work with the value OMAP_DSS_WB
of the enum parameter plane.

The value of this parameter is initialized in dss_init_overlays and in the
current state of the code it cannot take this value so it's not a real
problem.

For the purposes of defensive coding it wouldn't be superfluous to check
the parameter value, because some functions down the call stack process
this value correctly and some not.

For example, in dispc_ovl_setup_global_alpha it may lead to buffer
overflow.

Add check for this value.

Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.

Signed-off-by: Leonid Arapov <arapovl839@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/omap2/omapfb/dss/dispc.c

index 8db0748628242d0a7cbe47cb76be5d2ec32ed85a..1dc70c96d81326c8f778011bb2b7bcea7c17c516 100644 (file)
@@ -2733,9 +2733,13 @@ int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
                bool mem_to_mem)
 {
        int r;
-       enum omap_overlay_caps caps = dss_feat_get_overlay_caps(plane);
+       enum omap_overlay_caps caps;
        enum omap_channel channel;
 
+       if (plane == OMAP_DSS_WB)
+               return -EINVAL;
+
+       caps = dss_feat_get_overlay_caps(plane);
        channel = dispc_ovl_get_channel_out(plane);
 
        DSSDBG("dispc_ovl_setup %d, pa %pad, pa_uv %pad, sw %d, %d,%d, %dx%d ->"