Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3693891imu; Mon, 28 Jan 2019 09:10:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6iWhvF+9dnLxhE9/jLL18+GUYUfQRXm5WrY0khhPXCKdGJ/GD4LRplESio3l1Ame0ugJTx X-Received: by 2002:a62:670f:: with SMTP id b15mr22496675pfc.212.1548695405628; Mon, 28 Jan 2019 09:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695405; cv=none; d=google.com; s=arc-20160816; b=AKFN1nB3ESu6tbyNrwmrNdZxDOm00ji8n2oiOnf+2lB5wRyvUxO1a6B0xznSEnK8Kc ubcXSJlOEl7lgrEso10N8bDsH3XxkVi+QOY1DL4TRocmsVHV8z0mZ1Aw0AeFXw3v0Zpe geSIHQm20QDvv5rQzmArxxyocFJvvG7MpV0AYx3EivS8iHmcAcxDxKPmSF5EVOWi2aDD lrwNYjceaUtc1TEsNLPke2YtQ1N2jfIFz1zltZlFJF73OEDizajb2luKfrDRi1joMzmU aO6DfWtuMa98wCvvoh9kT85c0GKaMcO/vTseCxAJx8KUnuT/jWXwIIF+i3CyEDJyixS9 6E4g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xZupmLfrNrk4S/JQlah1ptRzvgDmj0+Y8qbaDgh98Ic=; b=NkE+tUnSmYTs1YRWOx/o1bmbkRtjQOqpCZwnKf1fauBSqixWJX4196yNnl/vRRJw5g T0faJR/BpOGS7DZUXJs3RBBQJoXv0WCbFSO0XUiXI08YSN7TifZGd+T26rROP+NO3Sc4 y2lWcatqmei/IH/DTwLgPwLuYvZpRYDr95+2ksmGCeLTjSYY0SbYKuU6d4fMGWVOw6DO 3bxT9H/lrCEq0KQrJZttgQuFZZrBVPha+MdnnuWjVj4xIl0qo+jMJAEN+b/TwAyuEewp 7D/kdVBsIZIpzRojiQNLFKLOCP+0DMiH9S8dlJ8YWRgFKqMHFLXjsB31jUBXzaD01z8C z9kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pA3bw7D0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y40si35199608pla.251.2019.01.28.09.09.50; Mon, 28 Jan 2019 09:10:05 -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=pA3bw7D0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732918AbfA1QLN (ORCPT + 99 others); Mon, 28 Jan 2019 11:11:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:38010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732912AbfA1QLL (ORCPT ); Mon, 28 Jan 2019 11:11:11 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 051892177E; Mon, 28 Jan 2019 16:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691870; bh=TMdF/Bwp5vt6JiHLx0cjYJVHG1iHptdfAOotXJeltlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pA3bw7D0eaCCDpYxRLS5POVOrDwiZ4l6shpAhzSclu2XqK634SZE37J3yfsPMSmsE Prr+uqNnSMqSE76xn2VNO7Zb5deD1+icOUZmNFn//u6V3zfY1sF/O4txX8gPjRaZnV KPHGai4Gcoma5mACwmKm4OSWsHnJXG6njzd5SFi8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Finn Thain , linuxppc-dev@lists.ozlabs.org, Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 243/258] block/swim3: Fix -EBUSY error when re-opening device after unmount Date: Mon, 28 Jan 2019 10:59:09 -0500 Message-Id: <20190128155924.51521-243-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Finn Thain [ 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 469541c1e51e..20907a0a043b 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1026,7 +1026,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