From nobody Tue Sep 16 09:00:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 340AEC3DA7A for ; Thu, 5 Jan 2023 14:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233114AbjAEOB5 (ORCPT ); Thu, 5 Jan 2023 09:01:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234455AbjAEOBW (ORCPT ); Thu, 5 Jan 2023 09:01:22 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1844A5D433 for ; Thu, 5 Jan 2023 05:59:38 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 583AF61; Thu, 5 Jan 2023 14:59:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672927176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=h9+LNjNMvVmywd8I9foM63O5f58OmDGIXfCuEIUwK4s=; b=sA6FQ9SCLIFbPi0NQnPI9DwvgqCB3nN7F6dJj2MgnoXE2H9W9HpZlYmlqQuhACEmu34+pt 4d/B1fEuhL2RVGVMkOSb8bX9y2n+6gPBpMfK0QyEOuZ7A0KXOPAA8Y+GbeGkcwRX1yludH qJe+/odyckr/zUBh1uiWSN8BNEOjNKNFMeHa/uuECy/5BIVS3XdStst1WNRbSxSwU1hqVM GIUDFojfm5mBd3jQPu4csq/GrSD9VRq42UrANUY6s7ei9QJJIY+85R6znL7Vt3kMP4sCn1 sxUoPaUqFaHtU8qtDlRjEa60eZcrNO+mTmVKcOf88esTVxqv1JeughkMLACABA== From: Michael Walle To: Srinivas Kandagatla , Alexander Stein Cc: Michael Walle , linux-kernel@vger.kernel.org, Miquel Raynal Subject: [PATCH] nvmem: core: return -ENOENT if nvmem cell is not found Date: Thu, 5 Jan 2023 14:59:31 +0100 Message-Id: <20230105135931.2743351-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Prior to commit 3cb05fdbaed6 ("nvmem: core: add an index parameter to the cell") of_nvmem_cell_get() would return -ENOENT if the cell wasn't found. Particularly, if of_property_match_string() returned -EINVAL, that return code was passed as the index to of_parse_phandle(), which then detected it as invalid and returned NULL. That led to an return code of -ENOENT. With the new code, the negative index will lead to an -EINVAL of of_parse_phandle_with_optional_args() which pass straight to the caller and break those who expect an -ENOENT. Fix it by always returning -ENOENT. Fixes: 3cb05fdbaed6 ("nvmem: core: add an index parameter to the cell") Reported-by: Alexander Stein Signed-off-by: Michael Walle Tested-by: Alexander Stein --- Alexander, could you give this another try? I've changed it slightly, so it's a better match with how the handling was before. drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 1b61c8bf0de4..cc885b602690 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1343,7 +1343,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_no= de *np, const char *id) "#nvmem-cell-cells", index, &cell_spec); if (ret) - return ERR_PTR(ret); + return ERR_PTR(-ENOENT); =20 if (cell_spec.args_count > 1) return ERR_PTR(-EINVAL); --=20 2.30.2