From: Sudip Mukherjee Date: Sun, 12 Jun 2016 15:03:56 +0000 (+0100) Subject: drm: fb: cma: fix memory leak X-Git-Tag: v5.15~13124^2~36^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a927623e864f98479c4be3c560ab8fbb0e0283c;p=platform%2Fkernel%2Flinux-starfive.git drm: fb: cma: fix memory leak We may have a situation that the memory allocation for fbdefio fails and then the allocation for fbops may succeed as some memory has been freed somewhere. Lets free fbops also to face these rare situtation. Since kfree can handle arguments as NULL, there should not be any problem in calling both the kfree(). Signed-off-by: Sudip Mukherjee Fixes: 199c77179c87 ("drm/fb-cma-helper: Add fb_deferred_io support") Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1465743836-6228-1-git-send-email-sudipm.mukherjee@gmail.com --- diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 2e7ef0b..c0b0c71 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -346,6 +346,7 @@ static int drm_fbdev_cma_defio_init(struct fb_info *fbi, fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); if (!fbdefio || !fbops) { kfree(fbdefio); + kfree(fbops); return -ENOMEM; }