]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
drm/msm: Fix possible null dereference on failure of get_pages()
authorBen Hutchings <ben.hutchings@codethink.co.uk>
Tue, 3 Apr 2018 22:38:45 +0000 (23:38 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 1 Oct 2018 12:55:21 +0000 (14:55 +0200)
commit36000de4422a28922e2533bce68292b02fea3b75
treecda8d0eda8fa0969a087c7dcc0c69e46d6d5c9ae
parent3b867e142dbd23ea2bbef1fc1017b9ed74a4ea39
drm/msm: Fix possible null dereference on failure of get_pages()

BugLink: http://bugs.launchpad.net/bugs/1794889
[ Upstream commit 3976626ea3d2011f8fd3f3a47070a8b792018253 ]

Commit 62e3a3e342af changed get_pages() to initialise
msm_gem_object::pages before trying to initialise msm_gem_object::sgt,
so that put_pages() would properly clean up pages in the failure
case.

However, this means that put_pages() now needs to check that
msm_gem_object::sgt is not null before trying to clean it up, and
this check was only applied to part of the cleanup code.  Move
it all into the conditional block.  (Strictly speaking we don't
need to make the kfree() conditional, but since we can't avoid
checking for null ourselves we may as well do so.)

Fixes: 62e3a3e342af ("drm/msm: fix leak in failed get_pages")
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/gpu/drm/msm/msm_gem.c