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 <sudip.mukherjee@codethink.co.uk>
Fixes: 199c77179c ("drm/fb-cma-helper: Add fb_deferred_io support")
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1465743836-6228-1-git-send-email-sudipm.mukherjee@gmail.com
This commit is contained in:
Sudip Mukherjee 2016-06-12 16:03:56 +01:00 committed by Daniel Vetter
parent cc22a86c26
commit 2a927623e8
1 changed files with 1 additions and 0 deletions

View File

@ -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;
}