From patchwork Tue May 9 19:03:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9819133 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 48452603D7 for ; Fri, 30 Jun 2017 10:16:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3991127F82 for ; Fri, 30 Jun 2017 10:16:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CBE728567; Fri, 30 Jun 2017 10:16:33 +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=-3.0 required=2.0 tests=BAYES_00, DATE_IN_PAST_96_XX, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 946C327F82 for ; Fri, 30 Jun 2017 10:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbdF3KQa (ORCPT ); Fri, 30 Jun 2017 06:16:30 -0400 Received: from iad1-shared-relay2.dreamhost.com ([208.113.157.41]:43861 "EHLO iad1-shared-relay2.dreamhost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751659AbdF3KQ1 (ORCPT ); Fri, 30 Jun 2017 06:16:27 -0400 Received: from iad1-shared-relay1.dreamhost.com (iad1-shared-relay1.dreamhost.com [208.113.157.50]) by iad1-shared-relay2.dreamhost.com (Postfix) with ESMTP id ED5DA3E51D7 for ; Thu, 29 Jun 2017 15:12:06 -0700 (PDT) Received: from ware.dreamhost.com (ware.dreamhost.com [64.111.127.160]) by iad1-shared-relay1.dreamhost.com (Postfix) with ESMTP id 2D43FB400A8 for ; Thu, 29 Jun 2017 15:12:06 -0700 (PDT) Received: by ware.dreamhost.com (Postfix, from userid 2406546) id B41DC100127; Thu, 29 Jun 2017 15:12:05 -0700 (PDT) In-Reply-To: <20170629134510.GA32385@infradead.org> References: <20170629134510.GA32385@infradead.org> From: Jan Kara Date: Tue, 9 May 2017 12:03:11 -0700 Subject: [PATCH 01/19] bcache: Fix leak of bdev reference To: linux-block@vger.kernel.org Message-Id: <20170629221205.B41DC100127@ware.dreamhost.com> 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 If blkdev_get_by_path() in register_bcache() fails, we try to lookup the block device using lookup_bdev() to detect which situation we are in to properly report error. However we never drop the reference returned to us from lookup_bdev(). Fix that. Signed-off-by: Jan Kara Cc: stable@vger.kernel.org --- drivers/md/bcache/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 8352fad..9a2c190 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1964,6 +1964,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, else err = "device busy"; mutex_unlock(&bch_register_lock); + if (!IS_ERR(bdev)) + bdput(bdev); if (attr == &ksysfs_register_quiet) goto out; }