From patchwork Mon Aug 23 07:33:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 1519558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=DY3cywqM; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=gCMffEP/; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GtPDc0jTTz9sWS for ; Mon, 23 Aug 2021 17:36:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+DNifQI25+4KkNVVbg6xWujOK4G0u5n6hx3GcCi6zpk=; b=DY3cywqMP1PFGZ LU4M/2KwClnHxpdQUxRwZIqUj7MyP6WJrL4s38po+bQlzz3B+sWdizDAJERfIbv7BjO2KbRhVQB6U AtGthCfym8pQdMOG+sTjW82ZyAuS6RL3Zt+YagoMAjRx4Jm0wjSj25va9Pp5f5arRTAsf+hFVGLIl xf8+bfwvACusMC/YLwTxxpXfBgfSW1dGmUS8USjXNu2B4VfsJTcIXrwBv1dUZFuEy2clUUR3TQau9 BCrJNUZnkMQvi2gvke03S6gPj8YeBVM46QX5c9s2CCOVoKrtMR3yU/KLf/TnI0bw08gRkTpbQzvXP jRbvXrS3rZBhilZbWmQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4UJ-00FkUN-5N; Mon, 23 Aug 2021 07:35:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4UH-00FkU1-Vx for linux-mtd@bombadil.infradead.org; Mon, 23 Aug 2021 07:35:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=2tzDZdLpuKXA+ygmvE34pMzvWGlwygVPE/R2irJ5MLo=; b=gCMffEP/BRk0dEPPUyj9UlH+Wf 5Nq9MqYwTnSYo/2I+R9/DGMjkbKkOLdIG8gv4XPhkUF42EECGOuK8MFUXaRR313l3h7djJnnvK3Ci eqpLnj8Bek91XVnL0De+G5LdcvZosu0XMwEXvImqkKPMCsR+1DtPOKb4fppfwCyN2rNxQNMijVH4E mTrm3189THKoG8n63sBXkAGFabQIXxa6vRgF2XP7o1aDdx9fhTRpZdWV3Zr1ufvrKhelXsFsLHw8C qJR5Yo0iOqa4ZhxRPAGMVbf0Yg1u48OiISuDE3t8BGlnYXre0RlDkLarjEdDLui0e23pMChUo/YBw n3WLEexw==; Received: from [2001:4bb8:193:fd10:c6e8:3c08:6f8b:cbf0] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI4Tc-009QhA-1K; Mon, 23 Aug 2021 07:34:45 +0000 From: Christoph Hellwig To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Guenter Roeck , linux-mtd@lists.infradead.org Subject: [PATCH 1/8] mtd_blkdevs: don't hold del_mtd_blktrans_dev in blktrans_{open, release} Date: Mon, 23 Aug 2021 09:33:52 +0200 Message-Id: <20210823073359.705281-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210823073359.705281-1-hch@lst.de> References: <20210823073359.705281-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org There is nothing that this protects against except for slightly reducing the window when new opens can appear just before calling del_gendisk. Reported-by: Guenter Roeck Signed-off-by: Christoph Hellwig Tested-by: Guenter Roeck --- drivers/mtd/mtd_blkdevs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 44bea3f65060..6b81a1c9ccbe 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -207,7 +207,6 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) if (!dev) return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ - mutex_lock(&mtd_table_mutex); mutex_lock(&dev->lock); if (dev->open) @@ -233,7 +232,6 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) unlock: dev->open++; mutex_unlock(&dev->lock); - mutex_unlock(&mtd_table_mutex); blktrans_dev_put(dev); return ret; @@ -244,7 +242,6 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) module_put(dev->tr->owner); kref_put(&dev->ref, blktrans_dev_release); mutex_unlock(&dev->lock); - mutex_unlock(&mtd_table_mutex); blktrans_dev_put(dev); return ret; } @@ -256,7 +253,6 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode) if (!dev) return; - mutex_lock(&mtd_table_mutex); mutex_lock(&dev->lock); if (--dev->open) @@ -272,7 +268,6 @@ static void blktrans_release(struct gendisk *disk, fmode_t mode) } unlock: mutex_unlock(&dev->lock); - mutex_unlock(&mtd_table_mutex); blktrans_dev_put(dev); }