Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: fbtft: core: fix potential memory leak in fbtft_probe_common()

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>

authored by

Jianglei Nie and committed by
Greg Kroah-Hartman
47d3949a e6ab5046

+2 -2
+2 -2
drivers/staging/fbtft/fbtft-core.c
··· 1171 1171 par->pdev = pdev; 1172 1172 1173 1173 if (display->buswidth == 0) { 1174 - dev_err(dev, "buswidth is not set\n"); 1175 - return -EINVAL; 1174 + ret = dev_err_probe(dev, -EINVAL, "buswidth is not set\n"); 1175 + goto out_release; 1176 1176 } 1177 1177 1178 1178 /* write register functions */