Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2717230imj; Mon, 11 Feb 2019 07:26:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IYjQ8pG61Vhpm8T30T33ZwMHLuOnqES5cczzl7fOH6XjD8/B5fPQQdxAMPeTCW8pnkCJhk1 X-Received: by 2002:a17:902:9b96:: with SMTP id y22mr24417955plp.179.1549898781543; Mon, 11 Feb 2019 07:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898781; cv=none; d=google.com; s=arc-20160816; b=vR8yVXnSSPD6+VDljINcp5VFDtH+BeUp4tI9mKrdD7ly1ddXCZ+OcU2VpJAacU+pyq Xd/IX7tIJqoRKehzjYSjLyy70/KTWQv5p+vInskiglsikQs14ivtW5tJEm5idOtmLqa1 zA4Cjx4b3Txjn+M4RKPThtr64LiyhuTbL0pkW2UXbQUW6b1YIV0trEzWViZnbsuU0ioa TfQt/bYM8Be1etxf0GPCO37kDlgMLA5H3i0R+ES+MaZkSIiyUwJUGTL9h7rU8+TvsQt/ LBiOTn9EQTHptbZvzuKZ5cTkC9Up7RJtQQxa8+MP8nZsRQBhKpT1Pf/NlyAxfng9bckT rSvA== 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=ZRYNMVe3jDzGIJyvnaqDOtDCm0BjWB0bFU/3l4ErvbU=; b=aL/46QI7BGCa9VRb0Lsl9sINrrfI/9ud1uTXjXy92iaq7EcNIee1ks0KR+gCZJYXcw Npwl6a2BUMHgHDl43KBgKnntzPhaIkVpqHqP0kxqTnf/nf7Skx5PIE+l6KPh3uHREKN/ 8xJdlfLyA3Ae0nFXpMF7xlmy84Bq+sA/8RO0+9d4EXUoWqDTGnA03J7k8yiIYd7Kn7Px 5MPnGFtab4Cu5TjpWm6cwF1YKe0NELFIymjxTlmryKZGXIU5NbGfbX/d+kuZOgPtAZ6a NJo5HduCuVS5VgtxiZZiQmY4Ii8W/tltXx+LcJgF6NSopqrxeTtk2QpsjK5Kf23GywoX Xeeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hxsOQDjY; 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 h3si9643708pgc.354.2019.02.11.07.26.04; Mon, 11 Feb 2019 07:26:21 -0800 (PST) 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=hxsOQDjY; 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 S2391121AbfBKPX7 (ORCPT + 99 others); Mon, 11 Feb 2019 10:23:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:51310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390524AbfBKPDB (ORCPT ); Mon, 11 Feb 2019 10:03:01 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 22626222AF; Mon, 11 Feb 2019 15:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897380; bh=iojwmthKxCQ/NFwwh14njk1F6PEB/40JDWJnQqgmG38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxsOQDjY4MsggB9XT03cv/8NpFpD0u1f46Yz0MHZr5PYyIPLO4u38LpCuVRgWyRMI QCEo1xN0IQ8RllZ1UXAZueIsAYrxwBkupScvfOD3LCdJvE7pCnZ+2yHyykTr5N47Rr qFKGW2nlpBRHig4VwY0ZPMrPgE5AHfZbkS01XLgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Finn Thain , Jens Axboe , Sasha Levin , Stan Johnson Subject: [PATCH 4.14 153/205] block/swim3: Fix -EBUSY error when re-opening device after unmount Date: Mon, 11 Feb 2019 15:19:11 +0100 Message-Id: <20190211141838.365059688@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 296dcc40f2f2e402facf7cd26cf3f2c8f4b17d47 ] When the block device is opened with FMODE_EXCL, ref_count is set to -1. This value doesn't get reset when the device is closed which means the device cannot be opened again. Fix this by checking for refcount <= 0 in the release method. Reported-and-tested-by: Stan Johnson Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Finn Thain Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/swim3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index 0d7527c6825a..2f7acdb830c3 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1027,7 +1027,11 @@ static void floppy_release(struct gendisk *disk, fmode_t mode) struct swim3 __iomem *sw = fs->swim3; mutex_lock(&swim3_mutex); - if (fs->ref_count > 0 && --fs->ref_count == 0) { + if (fs->ref_count > 0) + --fs->ref_count; + else if (fs->ref_count == -1) + fs->ref_count = 0; + if (fs->ref_count == 0) { swim3_action(fs, MOTOR_OFF); out_8(&sw->control_bic, 0xff); swim3_select(fs, RELAX); -- 2.19.1