]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fbdev: of: display_timing: fix refcount leak in of_get_display_timings()
authorWeigang He <geoffreyhe2@gmail.com>
Fri, 16 Jan 2026 09:57:51 +0000 (09:57 +0000)
committerHelge Deller <deller@gmx.de>
Sat, 14 Feb 2026 10:09:46 +0000 (11:09 +0100)
of_parse_phandle() returns a device_node with refcount incremented,
which is stored in 'entry' and then copied to 'native_mode'. When the
error paths at lines 184 or 192 jump to 'entryfail', native_mode's
refcount is not decremented, causing a refcount leak.

Fix this by changing the goto target from 'entryfail' to 'timingfail',
which properly calls of_node_put(native_mode) before cleanup.

Fixes: cc3f414cf2e4 ("video: add of helper for display timings/videomode")
Cc: stable@vger.kernel.org
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/of_display_timing.c

index bebd371c6b93eaea9f93239854d653fffbedff1c..1940c9505dd3b3f53b9ab6705f277152ed3f8e9f 100644 (file)
@@ -181,7 +181,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np)
        if (disp->num_timings == 0) {
                /* should never happen, as entry was already found above */
                pr_err("%pOF: no timings specified\n", np);
-               goto entryfail;
+               goto timingfail;
        }
 
        disp->timings = kcalloc(disp->num_timings,
@@ -189,7 +189,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np)
                                GFP_KERNEL);
        if (!disp->timings) {
                pr_err("%pOF: could not allocate timings array\n", np);
-               goto entryfail;
+               goto timingfail;
        }
 
        disp->num_timings = 0;