Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932087AbcCBBrk (ORCPT ); Tue, 1 Mar 2016 20:47:40 -0500 Received: from mail177-1.suw61.mandrillapp.com ([198.2.177.1]:60894 "EHLO mail177-1.suw61.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755056AbcCAXx5 (ORCPT ); Tue, 1 Mar 2016 18:53:57 -0500 From: Greg Kroah-Hartman Subject: [PATCH 3.14 069/130] virtio: fix memory leak of virtio ida cache layers X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Suman Anna , "Michael S. Tsirkin" Message-Id: <20160301234502.243891866@linuxfoundation.org> In-Reply-To: <20160301234459.768886030@linuxfoundation.org> References: <20160301234459.768886030@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.01d341b01b674919895b13a873c18b6b X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:53:37 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1231 Lines: 38 3.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Suman Anna 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: Greg Kroah-Hartman --- drivers/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -249,6 +249,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);