[PATCH] drm/i915: Fix a memory leak in intel_gvt_init_gtt()

Zhenyu Wang zhenyuw at linux.intel.com
Tue Jul 4 08:24:29 UTC 2017


On 2017.07.04 07:33:07 +0000, zhiyuan_zhu at htc.com wrote:
> From: Zhou, Wenjia <zhiyuan_zhu at htc.com>
> 
> It will causes memory leak, if the function setup_spt_oos() fail,
> in the function intel_gvt_init_gtt(),
> which allocated by get_zeroed_page() and mapped by dma_map_page().
> 
> Unmap and free the page,  after STP oos initialize fail,
> it will fix this issue.
> 
> Signed-off-by: Zhou, Wenjia <zhiyuan_zhu at htc.com>
> ---
> drivers/gpu/drm/i915/gvt/gtt.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/gtt.c  b/drivers/gpu/drm/i915/gvt/gtt.c
> index c6f0077..f2b352b 100644
> --- a/drivers/gpu/drm/i915/gvt/gtt.c
> +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> @@ -2254,6 +2254,8 @@ int intel_gvt_init_gtt(struct intel_gvt *gvt)
> 		ret = setup_spt_oos(gvt);
> 		if (ret) {
> 			gvt_err("fail to initialize SPT oos\n");
> +			dma_unmap_page(dev, daddr, 4096, PCI_DMA_BIDIRECTIONAL);
> +			__free_page(gvt->gtt.scratch_ggtt_page);
> 			return ret;
> 		}
> 	}


Looks there's minor conflicts then I apply this by hand.
Better to base against 'gvt-staging' branch of our tree
which is our tip develop master.

Thanks for the patch!

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170704/787a070d/attachment.sig>


More information about the intel-gvt-dev mailing list