Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1372688yba; Tue, 2 Apr 2019 07:43:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpmhyBcZbdbg/WRulw9JMR4q830+cYIRO6DsNvp5PHrSoLbRUevtZ1+UKdY/iLcWd0VMGw X-Received: by 2002:a17:902:2702:: with SMTP id c2mr69908835plb.239.1554216207784; Tue, 02 Apr 2019 07:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554216207; cv=none; d=google.com; s=arc-20160816; b=NRtEO5cNERQeAMWYJFnLTBEjCCPSwdEQrKLxvBiiJNYcR3sqXB7v2rRJeWghaymcEd 8cHOjZJzA8TxWyKYws+5kRKBBpUdC4LiWS76daQNHrHg0KwH8KnvY0+8ZmvJOvZHAY2c 4Un5zPSnQW6nPm3YYiye6ts09NErrusbuLaGRQFEcL7xeIQEzylfXcb0T/x1G50cfZ0U S4eHpaAH1C2muPmnkRjX/Q4wk75F6lvjU56KcYdA3MLFlZOePAKoKjvesmmLOhw9uS9K BKrhGZJooGeL+FX22dFs5y+hbQ9SVQIcJ5WEquyMARClL6S3AOFKo2iw6CAmg8jN08y9 eKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=maz6Pyw3xnFRVFjQDLulNwtxr1tV4ik4T6pfVX6rj7Y=; b=W3hDOOchbWLlTOL9IYc1TQ0V6YjUy49V8ccQpNfUnh9mUJzW/GsMFLQR6SCict188O 4NEGTGiklDgH1zvkRWdx6OcGsgcJo3EbqZp6QS2hr9dxFuBsjB6pOZV9FrCrZ7O98Bpe TbtOewNT99MKVx1/3QRquhkwFf+uuwkSSCI1ywHZh7mETwqaifvwrTo/Fp5mIib5/1ZD h95iu6u6Gq1waii4IGlRBEGQ45EQ1rgQptu6DPQ7GQB3eFx8vemdrT+N6kCf0MSrv4DC 1v43N1BZXLdduNcZGz/zFNtEzOhylIDoy05Ni3Q3NMA36J8Cs25vEsibV+jMPbDbNSzR X/vg== ARC-Authentication-Results: i=1; mx.google.com; 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 a1si3215925plp.120.2019.04.02.07.43.12; Tue, 02 Apr 2019 07:43:27 -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; 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 S1731838AbfDBNmd (ORCPT + 99 others); Tue, 2 Apr 2019 09:42:33 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43732 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731541AbfDBNkM (ORCPT ); Tue, 2 Apr 2019 09:40:12 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe4-0002p6-4f; Tue, 02 Apr 2019 14:40:08 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdy-0004xt-2s; Tue, 02 Apr 2019 14:40:02 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , linuxppc-dev@lists.ozlabs.org, "Finn Thain" , "Jens Axboe" Date: Tue, 02 Apr 2019 14:38:28 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 92/99] block/swim3: Fix -EBUSY error when re-opening device after unmount In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain commit 296dcc40f2f2e402facf7cd26cf3f2c8f4b17d47 upstream. 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: Ben Hutchings --- drivers/block/swim3.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -1027,7 +1027,11 @@ static void floppy_release(struct gendis 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);