]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/gvt: Fix a memory leak in intel_gvt_init_gtt()
authorZhou, Wenjia <zhiyuan_zhu@htc.com>
Tue, 4 Jul 2017 07:47:00 +0000 (15:47 +0800)
committerZhenyu Wang <zhenyuw@linux.intel.com>
Tue, 11 Jul 2017 05:46:58 +0000 (13:46 +0800)
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@htc.com>
Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
drivers/gpu/drm/i915/gvt/gtt.c

index 66374dba3b1a29800f5a03eda75d4282c0852337..6166e34d892b11c3bd6d219169bde81af1d112f0 100644 (file)
@@ -2259,6 +2259,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;
                }
        }