Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp605774pxb; Wed, 27 Jan 2021 16:32:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvyWlZciB9jFuvYvpZXn+Wj8IzRCh3J2hPO5PflaSgaZnQUiGze7Ch6KxpbaDDPd2aGTiT X-Received: by 2002:a17:906:3fc1:: with SMTP id k1mr9117211ejj.58.1611793934232; Wed, 27 Jan 2021 16:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611793934; cv=none; d=google.com; s=arc-20160816; b=gSRzxSqxqzIfdj4+DMPBfpdEqLSzLBRwD11senmtJSEXP4X3hnXvYMIFOU5ajBiYo3 yLfIOOpRugveCNNjQA2zqc2C/pTfYhxKokoWMefTYQ6UxFoDblHaBG9DkehABV1ZyJ3X gTCnwFnkNVZ8AZHnJB80y855fKijv1UrBm7w1prww7QFK8HLn76e9XVP0CyHUu6AmpsW kpCbN5TgFPO3t7dbxRzricjliFdISSb3nuGaboCIYcTj6qIJNzb2UPGslj+GGLWUdYMu ccfhBHModNWXXiruBB/rywB/L69qty5a+yZHK3CU6ymrwA5qOSQxmN55vVtbltQ8hGkU 22Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=fdLHvXovqzw49y+o+fcFzzjrdKCt0pJzuUdcx0b6Ens=; b=q7FZoK/hp6CsdvqcjNB5Htv3emHPx5qV+PAblsxLm8YyWRURkDO3h0y+KMWminJCsg Btlx13mrhh2mTQ3Lg34FxEsqVEimJIUImd/pIJdjtZhY3BKjJSL9mTHBQq1cwbM5RMHh FSziP2HY8hFbjcmNfWbaNPU8UVy6krvdDQsXN68GIUntH6yA1d9jxjamjXBzDMToCMUK cupkwySleUF9A8636karENxI9mb/AqxVXliRbRRrJAMk5zLdYpINuGzNWW+KCau+YPfi KLZTZ9yloZ440WM1C1we/luzJA30iau63L8z1XenSxc7qP8y8lCpdSnMgqnXu5bTLjYi dnwQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc5si1474257ejb.193.2021.01.27.16.31.50; Wed, 27 Jan 2021 16:32:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234054AbhA0VSk convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Jan 2021 16:18:40 -0500 Received: from lithops.sigma-star.at ([195.201.40.130]:42390 "EHLO lithops.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344101AbhA0VSd (ORCPT ); Wed, 27 Jan 2021 16:18:33 -0500 Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 86D24625DE1E; Wed, 27 Jan 2021 22:17:51 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 79ZlmV87B62C; Wed, 27 Jan 2021 22:17:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 244DB625DE1C; Wed, 27 Jan 2021 22:17:51 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pgoXEc18aL20; Wed, 27 Jan 2021 22:17:51 +0100 (CET) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id F3E4E625DE1E; Wed, 27 Jan 2021 22:17:50 +0100 (CET) Date: Wed, 27 Jan 2021 22:17:50 +0100 (CET) From: Richard Weinberger To: Tomas Winkler Cc: Miquel Raynal , Vignesh Raghavendra , linux-mtd , linux-kernel Message-ID: <1776363776.325713.1611782270873.JavaMail.zimbra@nod.at> In-Reply-To: References: <20210127200319.662842-1-tomas.winkler@intel.com> <9732911.325628.1611780400338.JavaMail.zimbra@nod.at> Subject: Re: [PATCH] mtd: use refcount to prevent corruption MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF78 (Linux)/8.8.12_GA_3809) Thread-Topic: use refcount to prevent corruption Thread-Index: AQHW9OeD00Da249Jw0qJn6+VIZAeUao7z7AAgAAh5BBxoBSOfA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Ursprüngliche Mail ----- >> > When underlying device is removed mtd core will crash in case user >> > space is still holding an open handle to a mtd device node. >> > A proper refcounting is needed so device is release only when a >> > partition has no active users. The current simple counter is not >> > sufficient. >> >> Can you please explain a little more what devices are involved? >> Does it implement _get_device() and _put_device()? > No this is not connected to those handlers of the underlying device and those > won't help. > I have a spi device provided by MFD framework so it can go away anytime. Can it go away physically or just in software? Usually the pattern is that you make sure in the device driver that nobody can orphan the MTD while it is in use. e.g. drivers/mtd/ubi/gluebi.c does so. In _get_device() it grabs a reference on the underlying UBI volume to make sure it cannot go away while the MTD (on top of UBI) is in use. Thanks, //richard