Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9101737pxu; Mon, 28 Dec 2020 06:40:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVKOP+d2UO8p2RCGu55I7fLvlxlh8kjNAUzs12aLonx/qjZRMNtANF7iwv6b4R/7bK0Ted X-Received: by 2002:a17:907:414c:: with SMTP id od20mr41540463ejb.75.1609166457827; Mon, 28 Dec 2020 06:40:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166457; cv=none; d=google.com; s=arc-20160816; b=u13lV2NFmdCfcT7jaiBBDuzBJgIPK6Zj47vYNco58TG8pLf28wY4fmtAVPe/ZAstCD ZHLDW4H+s7eebEJNNed0PCdTG4WJhHZHE9Lw/qy101eID0BcaZD6hqjg+d8y2dJKQnMN vtAy4lL5CZCrsenMLEmRleZQj4w3SAjkPJmc6W5dwbyIOQ6aY1iaM3xzQZcVL3cmlyMX ep5q+MTsUH/zMPtjJ0aLbWx/+ySb1iOEAwuV0UwLn8ILOyBR9Oa3Kfoqx0b5bqYoQmGS rIWKlrnIIfJuSNeQhXHlmkDiT++ShoelOaSggwYUT1dGbMb+OIfGSWPu+QKFM3MquxAL lQfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u57BU2X30dvHCg2wTY0HSwgUpy1J7WpIHw6PEbvNXKI=; b=LOa6GgrYN9XzlpTsD5+Gp0y0+nXS1dvwgc6N1+rC8ZqJZdC0LjGv9+GQFkBbHI6pSe IIXZzdT++G1iqTEjPIAd1LulfZvwRndF25hFE71zQ5K6Ga1B+sqbcE03vDhREBOkCtpQ y0Yzi6t1FdRE3Nc9kqB9XtczJiBDSRp6IOQ3sXdLAfW8sPc4QzaajrQL8AI37EsSlC0H nqcDIt9C7qv1ovL3ta9ojHxwQjw3jguQAcS3aY9AkZX8b0y+oo4XS+MVqRcyPc2l5lqf rR1k40zO48BLDQFOhrkXTvpmt0Wh3N+o5FcfdIQ9sv054gwpt8Dl8DE+SW/TI2zXCLO3 1Cnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rsvU26eW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si10693635ejr.370.2020.12.28.06.40.34; Mon, 28 Dec 2020 06:40:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rsvU26eW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392099AbgL1Obu (ORCPT + 99 others); Mon, 28 Dec 2020 09:31:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:39246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504107AbgL1ObB (ORCPT ); Mon, 28 Dec 2020 09:31:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC15420715; Mon, 28 Dec 2020 14:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165821; bh=w2MbZqHrbnV1/3vTaIVxhKkrqqnlg4ERx7+X5Is3acI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rsvU26eWK13TazqIE2JHkxpH0AWXXJpmyziCwFS3iz4DujYfZduk2IEv7nDxSnLDr Lkso3fmwwpiuQvrdKM5KkbiIqe0ENUd8XIYvbfJEz+BlvvIX4CFbhGwihZ7EKesvLp FbG+y+Y3cwfmUlk6ERKgrNeWihWyjXIWAQOFxaik= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger , Miquel Raynal Subject: [PATCH 5.10 666/717] mtd: core: Fix refcounting for unpartitioned MTDs Date: Mon, 28 Dec 2020 13:51:04 +0100 Message-Id: <20201228125052.887156137@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Weinberger commit 1ca71415f075353974524e96ed175306d8a937a8 upstream. Apply changes to usecount also to the master partition. Otherwise we have no refcounting at all if an MTD has no partitions. Cc: stable@vger.kernel.org Fixes: 46b5889cc2c5 ("mtd: implement proper partition handling") Signed-off-by: Richard Weinberger Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20201206202220.27290-1-richard@nod.at Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/mtdcore.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -993,6 +993,8 @@ int __get_mtd_device(struct mtd_info *mt } } + master->usecount++; + while (mtd->parent) { mtd->usecount++; mtd = mtd->parent; @@ -1059,6 +1061,8 @@ void __put_mtd_device(struct mtd_info *m mtd = mtd->parent; } + master->usecount--; + if (master->_put_device) master->_put_device(master);