From patchwork Tue Feb 6 16:05:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10203251 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 9E0B5605BA for ; Tue, 6 Feb 2018 16:05:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91E0F28C94 for ; Tue, 6 Feb 2018 16:05:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86AA628C96; Tue, 6 Feb 2018 16:05:46 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4827528C94 for ; Tue, 6 Feb 2018 16:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752439AbeBFQFo (ORCPT ); Tue, 6 Feb 2018 11:05:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:35998 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752477AbeBFQFm (ORCPT ); Tue, 6 Feb 2018 11:05:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 782ACAE95; Tue, 6 Feb 2018 16:05:39 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 52E2E1E055E; Tue, 6 Feb 2018 17:05:38 +0100 (CET) From: Jan Kara To: Cc: Jens Axboe , Tejun Heo , Hou Tao , Eric Biggers , Jan Kara , Christoph Hellwig Subject: [PATCH 1/6] genhd: Fix leaked module reference for NVME devices Date: Tue, 6 Feb 2018 17:05:24 +0100 Message-Id: <20180206160529.20713-2-jack@suse.cz> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180206160529.20713-1-jack@suse.cz> References: <20180206160529.20713-1-jack@suse.cz> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 8ddcd653257c "block: introduce GENHD_FL_HIDDEN" added handling of hidden devices to get_gendisk() but forgot to drop module reference which is also acquired by get_disk(). Drop the reference as necessary. Arguably the function naming here is misleading as put_disk() is *not* the counterpart of get_disk() but let's fix that in the follow up commit since that will be more intrusive. Fixes: 8ddcd653257c18a669fcb75ee42c37054908e0d6 CC: Christoph Hellwig Signed-off-by: Jan Kara --- block/genhd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/genhd.c b/block/genhd.c index 96a66f671720..22f4fc340a3a 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -802,7 +802,10 @@ struct gendisk *get_gendisk(dev_t devt, int *partno) } if (disk && unlikely(disk->flags & GENHD_FL_HIDDEN)) { + struct module *owner = disk->fops->owner; + put_disk(disk); + module_put(owner); disk = NULL; } return disk;