From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A237912C462; Tue, 30 Apr 2024 10:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474552; cv=none; b=FD/njwn9mz0hgxqBXpmUjVKiGxSdfRMqvDjgtUNdDBcMKBLyXHiyyleXXXBRWvkKbIPGMSWYT+aVdY1BR3iOpwNhnHJ87hPja7ztsgt2RXXVv5x8QJOQsqIsLGFHc/6FYAylk5uLDjw85mhGkfPoUt4+LWv4iwVHG2/vG6JHncc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714474552; c=relaxed/simple; bh=CnPL1QINPj4EANswjwcDm1Z9IhPMqHexVW1UlPrCgWI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uo2gv86d+dJYA8aPpRSXC5ayaRUbYIJfmZjmrk3M3Q0XWBuZ3eXNY53dzyfybDJ8DDL0SQtxWUHCcFYpFMjDqJZWw5z8szLPEWP2/P4oT2UtE3eeaN2eszRZ9WFlhEoODLHyATMy2FvfKJBv5GrH7VLVall4NS0fM3qa8uHQL6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0oFnXUNt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0oFnXUNt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11D10C4AF19; Tue, 30 Apr 2024 10:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714474552; bh=CnPL1QINPj4EANswjwcDm1Z9IhPMqHexVW1UlPrCgWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0oFnXUNtQ6zmOh1fw9aNc/6RbfNvxPmxTpdQ+jFP6pPXpQ2DK6+9D1DXbUqdd8wZs B0wg9XOhVu55eWTtSMDXQeDx5wXyW2trtOC07uq17gikQswmMdGLL2EF0SY3Hp9tR9 lhAZEhF/hJGnIepDc3aRSnvSFWLKYA6sFjLNlf8M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Marangi , Miquel Raynal Subject: [PATCH 6.8 193/228] mtd: limit OTP NVMEM cell parse to non-NAND devices Date: Tue, 30 Apr 2024 12:39:31 +0200 Message-ID: <20240430103109.368580430@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103103.806426847@linuxfoundation.org> References: <20240430103103.806426847@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Marangi commit d2d73a6dd17365c43e109263841f7c26da55cfb0 upstream. MTD OTP logic is very fragile on parsing NVMEM cell and can be problematic with some specific kind of devices. The problem was discovered by e87161321a40 ("mtd: rawnand: macronix: OTP access for MX30LFxG18AC") where OTP support was added to a NAND device. With the case of NAND devices, it does require a node where ECC info are declared and all the fixed partitions, and this cause the OTP codepath to parse this node as OTP NVMEM cells, making probe fail and the NAND device registration fail. MTD OTP parsing should have been limited to always using compatible to prevent this error by using node with compatible "otp-user" or "otp-factory". NVMEM across the years had various iteration on how cells could be declared in DT, in some old implementation, no_of_node should have been enabled but now add_legacy_fixed_of_cells should be used to disable NVMEM to parse child node as NVMEM cell. To fix this and limit any regression with other MTD that makes use of declaring OTP as direct child of the dev node, disable add_legacy_fixed_of_cells if we detect the MTD type is Nand. With the following logic, the OTP NVMEM entry is correctly created with no cells and the MTD Nand is correctly probed and partitions are correctly exposed. Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support") Cc: # v6.7+ Signed-off-by: Christian Marangi Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20240412105030.1598-1-ansuelsmth@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -900,7 +900,7 @@ static struct nvmem_device *mtd_otp_nvme config.name = compatible; config.id = NVMEM_DEVID_AUTO; config.owner = THIS_MODULE; - config.add_legacy_fixed_of_cells = true; + config.add_legacy_fixed_of_cells = !mtd_type_is_nand(mtd); config.type = NVMEM_TYPE_OTP; config.root_only = true; config.ignore_wp = true;