From patchwork Tue Dec 19 19:29:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 10124077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E76FA6019C for ; Tue, 19 Dec 2017 19:37:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D95B32924D for ; Tue, 19 Dec 2017 19:37:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE4452951E; Tue, 19 Dec 2017 19:37:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 595EB2924D for ; Tue, 19 Dec 2017 19:37:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 114B46E34C; Tue, 19 Dec 2017 19:36:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id F04756E334 for ; Tue, 19 Dec 2017 19:36:31 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 11:36:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018508" Received: from downor-z87x-ud5h.fm.intel.com ([10.1.122.11]) by orsmga007.jf.intel.com with ESMTP; 19 Dec 2017 11:36:31 -0800 From: Dongwon Kim To: linux-kernel@vger.kernel.org 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 Cc: xen-devel@lists.xenproject.org, mateuszx.potrola@intel.com, dri-devel@lists.freedesktop.org, dongwon.kim@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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; }