]> git.baikalelectronics.ru Git - kernel.git/commit
drm/vc4: Fix resource leak in 'vc4_get_hang_state_ioctl()' in error handling path
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 12 May 2017 12:38:03 +0000 (14:38 +0200)
committerEric Anholt <eric@anholt.net>
Tue, 13 Jun 2017 00:11:39 +0000 (17:11 -0700)
commit014be6c8e7b9da098a337e32fb38e4d5a77f329a
tree478890f4ecd797fd31e89b1e8b7b66e00f3f5801
parent1a7e13deaa5ab2bef4cb00637f8c011df29dc73b
drm/vc4: Fix resource leak in 'vc4_get_hang_state_ioctl()' in error handling path

If one 'drm_gem_handle_create()' fails, we leak somes handles and some
memory.

In order to fix it:
  - move the 'free(bo_state)' at the end of the function so that it is also
    called in the eror handling path. This has the side effect to also try
    to free it if the first 'kcalloc' fails. This is harmless.
  - add a new label, err_delete_handle, in order to delete already
    allocated handles in error handling path
  - remove the now useless 'err' label

The way the code is now written will also delete the handles if the
'copy_to_user()' call fails.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: http://patchwork.freedesktop.org/patch/msgid/20170512123803.1886-1-christophe.jaillet@wanadoo.fr
drivers/gpu/drm/vc4/vc4_gem.c