Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2751672imj; Mon, 11 Feb 2019 07:58:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ1sNZ/WayMXAdROAAFt9SvT9Z6yx2VDBjuUyV08J9tRDORjglkVy+C1atr7OnjRRtpNO7N X-Received: by 2002:a63:da18:: with SMTP id c24mr18183801pgh.318.1549900709507; Mon, 11 Feb 2019 07:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900709; cv=none; d=google.com; s=arc-20160816; b=c8zmnSIcsU0eXnuQrEhgR0cSsWFUpnpc2Yreeeob3Ky+r9IXN1wxQLX2FRlQiiT13a XVfyJSZsjNpclxJwmgFdv27Yx2rYjyZu3ixyatRfD1qf7mkmggjNV+FHwasejdDff5k0 e2+nc52424sGBHMmm/2ASciJvtHsvcA0HZY+FQebhVra3/MJM5GxcaAIw+sR7r+vX+NN 9tCnW4nHacbm81Suw87HFcx01xy8V0hgMb+7Z1pQ8muowhrlNGV+ozsuX/kBvFwbMewW DxdNQCGGRtjPdFRViDzS+W5mUOmybujdStCuk0Js4dppV2O1oj/QETsgyzOBm9NqzT1Z Fsdg== 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=RSiGQIUsp2y26Z4zI0F4yYiIPom+3STsotYdMNssH8g=; b=uqmr+v1WtDX7BBLuAFMJRoR7wLyzsE47G4W3abgWDM0mLjQZOOlWgJPjFQ7NiGBc5w ghp8gaVU7FDRz0HbiBsioAORm273l8Z8qTCYzH0PcYoF2pspSrqLYN1IF4GbM1tlLOeN N1H/2Cnraxm4x4iEw0SmKh2sYr8owWjeKNO9rys3W6010JGyRwIEF9upHOpb0OQTOn6x aEmfZaS3g2NAI+PbXrTkoRr5T+rueBBDze20jn+HAVJlxRkVflvtd/gGPQGb0zQRlpP7 sseQqyfMuEM9MODfOm0HTuNkPY/5c4ycm+n8FV5eCjwVjgc5XR+bQ4Ji5cGRXP+12DJU U9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="V4/rW+xJ"; 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 z13si8744932pgf.294.2019.02.11.07.58.12; Mon, 11 Feb 2019 07:58:29 -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="V4/rW+xJ"; 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 S1731077AbfBKP4t (ORCPT + 99 others); Mon, 11 Feb 2019 10:56:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:42190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730486AbfBKOeE (ORCPT ); Mon, 11 Feb 2019 09:34:04 -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 6E2BE206B7; Mon, 11 Feb 2019 14:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895643; bh=PMjMsMqB/V9zJCPlX2kWtTrDJ1KrGRYad9kcHa7PLz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V4/rW+xJDn3XdrjXjb49OlYmOLfzKG1obVa+3/5/vt0dZkTE99Y2AhYBSG8UqN6T1 YPQTiXB9ML2KqYrEXkYb/71sOw5cYWK+bcsG38sNEud1oUD+g2xJO/GGvVIxdGQ0H3 lcVJxPl3Ylm3DoBiDY4HtauSZ8sTMAMiCehDugQg= 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.20 273/352] block/swim3: Fix -EBUSY error when re-opening device after unmount Date: Mon, 11 Feb 2019 15:18:20 +0100 Message-Id: <20190211141904.347218860@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 c1c676a33e4a..3f6df3f1f5d9 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -995,7 +995,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