]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: fbtft: core: fix potential memory leak in fbtft_probe_common()
authorJianglei Nie <niejianglei2021@163.com>
Wed, 12 Nov 2025 19:22:07 +0000 (20:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Nov 2025 16:53:46 +0000 (17:53 +0100)
fbtft_probe_common() allocates a memory chunk for "info" with
fbtft_framebuffer_alloc(). When "display->buswidth == 0" is true, the
function returns without releasing the "info", which will lead to a
memory leak.

Fix it by calling fbtft_framebuffer_release() when "display->buswidth
== 0" is true.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Abdun Nihaal <abdun.nihaal@gmail.com>
Link: https://patch.msgid.link/20251112192235.2088654-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fbtft/fbtft-core.c

index 9e7b84071174cff31d04557a65285061152c3c40..8a5ccc8ae0a188f1a03e4c5e2488be8cc6ae0bbe 100644 (file)
@@ -1171,8 +1171,8 @@ int fbtft_probe_common(struct fbtft_display *display,
        par->pdev = pdev;
 
        if (display->buswidth == 0) {
-               dev_err(dev, "buswidth is not set\n");
-               return -EINVAL;
+               ret = dev_err_probe(dev, -EINVAL, "buswidth is not set\n");
+               goto out_release;
        }
 
        /* write register functions */