Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1061296ybl; Wed, 14 Aug 2019 10:05:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqya5FxS7F43i7I7NXNmZAy2l/bPxaEwLEM0ueHfpxcYEbbtZA2E4v3VzJK9zsI04LDq9von X-Received: by 2002:a17:90a:f011:: with SMTP id bt17mr696668pjb.21.1565802344704; Wed, 14 Aug 2019 10:05:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802344; cv=none; d=google.com; s=arc-20160816; b=Ol2fxChiyMrD+IwSQ79aRzYTzs8w/twUmyGuVDUHZPaj3J00eAYnNWT7UbIqDRngO9 IqvLWpC8xbJB613WnhS8P1zmqDAKetFJLb699fudOyreW42m8Ld3yszFQlvF8MoCxl1M 9u5aYr5tzInKECa1HNy1oyIKLMGlNXG/54YKFiNjHixji73ALDgicU/U75fFiNBF8ZYo cRdaHpQ+HtzfATMaFJrlfkbKcZXvnYgViyDr5T6yvVJeDIcFZXOg7AgCnoJOKcmJNssi 5zXSjArIGdn+ackHQg00zgdrKLuJHNDVtEDzaH3TrLgnNK31oDR0TxueHp2AvWFv9adR 9l1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2TF+FJKVr/CIpt3D+w+schw91vi7V5I8VZ+QiYBF44Y=; b=k0pTNOfKjob9xMl1VW2shpS+lNWCW32Dg7zbARx4w0PaKF49owOYwuei73nPO8yY7h /6Yye/cCsg6sWeAsc0LByjs/gBJNNGFYxEAYkRFqxjhpcasb8OdYp8o0PHaP8Y+SGM5L FXeWJAimxD8vx9v1UOh0aeBSbZ5IVE79QYYdyfWMAW+Muj0QkrPSQPtl5xiNXVBjlUII WqCwt0Xm+DWiuPSgYCOK4PKCumUS5x0/K4IP3OqfnXQIvJN7reja/F9UU7WCJLWQE6+s pVhGVLDQZM+hP/mzjyTkMb3u1GEyvL+ZrVPGgPKnQCxszvU8yC55iIY0+3UqdruY9WD4 lQPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=H+eM4aJi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si157659pgt.568.2019.08.14.10.05.28; Wed, 14 Aug 2019 10:05:44 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=H+eM4aJi; 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 S1728014AbfHNRC6 (ORCPT + 99 others); Wed, 14 Aug 2019 13:02:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbfHNRC5 (ORCPT ); Wed, 14 Aug 2019 13:02:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 89D9C208C2; Wed, 14 Aug 2019 17:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802176; bh=v1ncVUEw5omDh/lN+fYExxW5ZP8v8Cu9WRF1leWKklk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+eM4aJivF595pb/jSRzIJi2p7cE64nNHsiH/lR3Dagwbrm1zW0OqA2KaBm0jVc/I 9Kg1y13kAK1db9njgnmJcn4bwJU8AGMOwpH//tz6/nC26M6p/OtGr15M7xTN7Jzdg4 tGSkLTUxG7vyg+mKK3AMqQmByuIEo/7EwwKw+UcQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Jens Axboe Subject: [PATCH 5.2 023/144] bdev: Fixup error handling in blkdev_get() Date: Wed, 14 Aug 2019 18:59:39 +0200 Message-Id: <20190814165800.813745526@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit e91455bad5cff40a8c232f2204a5104127e3fec2 upstream. Commit 89e524c04fa9 ("loop: Fix mount(2) failure due to race with LOOP_SET_FD") converted blkdev_get() to use the new helpers for finishing claiming of a block device. However the conversion botched the error handling in blkdev_get() and thus the bdev has been marked as held even in case __blkdev_get() returned error. This led to occasional warnings with block/001 test from blktests like: kernel: WARNING: CPU: 5 PID: 907 at fs/block_dev.c:1899 __blkdev_put+0x396/0x3a0 Correct the error handling. CC: stable@vger.kernel.org Fixes: 89e524c04fa9 ("loop: Fix mount(2) failure due to race with LOOP_SET_FD") Signed-off-by: Jan Kara Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/block_dev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1723,7 +1723,10 @@ int blkdev_get(struct block_device *bdev /* finish claiming */ mutex_lock(&bdev->bd_mutex); - bd_finish_claiming(bdev, whole, holder); + if (!res) + bd_finish_claiming(bdev, whole, holder); + else + bd_abort_claiming(bdev, whole, holder); /* * Block event polling for write claims if requested. Any * write holder makes the write_holder state stick until