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

video: fbdev: savage: fix memory leak on error handling path in probe

savagefb_probe() calls savage_init_fb_info() that can successfully
allocate memory for info->pixmap.addr but then fail when
fb_alloc_cmap() fails. savagefb_probe() goes to label failed_init and
does not free allocated memory. It is not valid to go to label
failed_mmio since savage_init_fb_info() can fail during memory
allocation as well. So, the patch free allocated memory on the error
handling path in savage_init_fb_info() itself.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Cc: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200619162136.9010-1-novikov@ispras.ru

authored by

Evgeny Novikov and committed by
Bartlomiej Zolnierkiewicz
e8d35898 17d8dcf5

+2
+2
drivers/video/fbdev/savage/savagefb_driver.c
··· 2157 2157 info->flags |= FBINFO_HWACCEL_COPYAREA | 2158 2158 FBINFO_HWACCEL_FILLRECT | 2159 2159 FBINFO_HWACCEL_IMAGEBLIT; 2160 + else 2161 + kfree(info->pixmap.addr); 2160 2162 } 2161 2163 #endif 2162 2164 return err;