Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753205AbdLSTub (ORCPT ); Tue, 19 Dec 2017 14:50:31 -0500 Received: from mga01.intel.com ([192.55.52.88]:17636 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752875AbdLSTgd (ORCPT ); Tue, 19 Dec 2017 14:36:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018508" From: Dongwon Kim To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, mateuszx.potrola@intel.com, dongwon.kim@intel.com Subject: [RFC PATCH 10/60] hyper_dmabuf: make sure to free memory to prevent leak Date: Tue, 19 Dec 2017 11:29:26 -0800 Message-Id: <1513711816-2618-10-git-send-email-dongwon.kim@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> References: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3190 Lines: 84 From: Mateusz Polrola In hyper_dmabuf_export_remote, page_info->pages needs to be freed before freeing page_info. Also, info_entry in hyper_dmabuf_remove_exported/imported and hyper_dmabuf_remove_exporter/importer_ring needs to be freed after removal of an entry. Signed-off-by: Dongwon Kim --- drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c | 1 + drivers/xen/hyper_dmabuf/hyper_dmabuf_list.c | 2 ++ drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm.c | 2 ++ drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm_list.c | 2 ++ 4 files changed, 7 insertions(+) diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c index bace8b2..6f100ef 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c @@ -191,6 +191,7 @@ static int hyper_dmabuf_export_remote(void *data) /* free msg */ kfree(req); /* free page_info */ + kfree(page_info->pages); kfree(page_info); return ret; diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_list.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_list.c index 2b3ef6b..1420df9 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_list.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_list.c @@ -98,6 +98,7 @@ int hyper_dmabuf_remove_exported(int id) hash_for_each(hyper_dmabuf_hash_exported, bkt, info_entry, node) if(info_entry->info->hyper_dmabuf_id == id) { hash_del(&info_entry->node); + kfree(info_entry); return 0; } @@ -112,6 +113,7 @@ int hyper_dmabuf_remove_imported(int id) hash_for_each(hyper_dmabuf_hash_imported, bkt, info_entry, node) if(info_entry->info->hyper_dmabuf_id == id) { hash_del(&info_entry->node); + kfree(info_entry); return 0; } diff --git a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm.c b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm.c index 576085f..116850e 100644 --- a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm.c +++ b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm.c @@ -320,6 +320,8 @@ int hyper_dmabuf_importer_ringbuf_init(int sdomain) ring_info->unmap_op.handle = ops[0].handle; } + kfree(ops); + sring = (struct hyper_dmabuf_sring*) pfn_to_kaddr(page_to_pfn(shared_ring)); BACK_RING_INIT(&ring_info->ring_back, sring, PAGE_SIZE); diff --git a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm_list.c b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm_list.c index 5778468..a068276 100644 --- a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm_list.c +++ b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_comm_list.c @@ -85,6 +85,7 @@ int hyper_dmabuf_remove_exporter_ring(int domid) hash_for_each(hyper_dmabuf_hash_exporter_ring, bkt, info_entry, node) if(info_entry->info->rdomain == domid) { hash_del(&info_entry->node); + kfree(info_entry); return 0; } @@ -99,6 +100,7 @@ int hyper_dmabuf_remove_importer_ring(int domid) hash_for_each(hyper_dmabuf_hash_importer_ring, bkt, info_entry, node) if(info_entry->info->sdomain == domid) { hash_del(&info_entry->node); + kfree(info_entry); return 0; } -- 2.7.4