From patchwork Fri Mar 4 09:01:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 63556 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp356777lbc; Fri, 4 Mar 2016 01:28:46 -0800 (PST) X-Received: by 10.66.191.225 with SMTP id hb1mr10510711pac.78.1457083723207; Fri, 04 Mar 2016 01:28:43 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si4689025pfq.45.2016.03.04.01.28.42; Fri, 04 Mar 2016 01:28:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759422AbcCDJ2c (ORCPT + 30 others); Fri, 4 Mar 2016 04:28:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:59915 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758999AbcCDJDW (ORCPT ); Fri, 4 Mar 2016 04:03:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ED052ADCC; Fri, 4 Mar 2016 09:03:17 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Suman Anna , "Michael S . Tsirkin" , Jiri Slaby Subject: [PATCH 3.12 062/116] virtio: fix memory leak of virtio ida cache layers Date: Fri, 4 Mar 2016 10:01:47 +0100 Message-Id: <8c4cb2a75a22b5720342899496123c4c78939640.1457082108.git.jslaby@suse.cz> X-Mailer: git-send-email 2.7.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suman Anna 3.12-stable review patch. If anyone has any objections, please let me know. -- 2.7.2 =============== commit c13f99b7e945dad5273a8b7ee230f4d1f22d3354 upstream. The virtio core uses a static ida named virtio_index_ida for assigning index numbers to virtio devices during registration. The ida core may allocate some internal idr cache layers and an ida bitmap upon any ida allocation, and all these layers are truely freed only upon the ida destruction. The virtio_index_ida is not destroyed at present, leading to a memory leak when using the virtio core as a module and atleast one virtio device is registered and unregistered. Fix this by invoking ida_destroy() in the virtio core module exit. Signed-off-by: Suman Anna Signed-off-by: Michael S. Tsirkin Signed-off-by: Jiri Slaby --- drivers/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index ee59b74768d9..beaa7cc4e857 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -238,6 +238,7 @@ static int virtio_init(void) static void __exit virtio_exit(void) { bus_unregister(&virtio_bus); + ida_destroy(&virtio_index_ida); } core_initcall(virtio_init); module_exit(virtio_exit);