Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933598AbdIXUnw (ORCPT ); Sun, 24 Sep 2017 16:43:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933518AbdIXUnt (ORCPT ); Sun, 24 Sep 2017 16:43:49 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Coly Li , Jens Axboe Subject: [PATCH 4.13 094/109] bcache: Fix leak of bdev reference Date: Sun, 24 Sep 2017 22:33:55 +0200 Message-Id: <20170924203356.882083374@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170924203353.104695385@linuxfoundation.org> References: <20170924203353.104695385@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 997 Lines: 34 4.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit 4b758df21ee7081ab41448d21d60367efaa625b3 upstream. 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 Acked-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/super.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1965,6 +1965,8 @@ static ssize_t register_bcache(struct ko else err = "device busy"; mutex_unlock(&bch_register_lock); + if (!IS_ERR(bdev)) + bdput(bdev); if (attr == &ksysfs_register_quiet) goto out; }