Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp930319rwl; Thu, 5 Jan 2023 06:34:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIJ3SyslbdBZePqGLa/UPOKK6qgyzdqvepiBQpbaG3zshGx9uwvcatea95AXQIQMLZRB26 X-Received: by 2002:a17:902:7c8a:b0:192:835d:c861 with SMTP id y10-20020a1709027c8a00b00192835dc861mr33732360pll.68.1672929294114; Thu, 05 Jan 2023 06:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672929294; cv=none; d=google.com; s=arc-20160816; b=Yml0Jm1fcoU/PAxxjV20lJPp9w44BiSQ5RJ0zcSCWHk7QnCLGO7rKyQZILEarfrE1w L2O6e3PYsL1K8y1seiYDxgKlgNlj5O53jVJ+fOiLJg/vSzkRhA5A+ma+ANDb8kC7sxTD shop54QoFWKoxs+CGRHJtZS1QTxW4joip8hwYb17W1oGej8whVPHs8H2j6aswA7/D8Yd w9R27Rg3PT8NdkIqo+eJ4RqHgz/DsNREkiS04BKdcaATjIhMc4SViASHJPWRygyIhQeY Hxly8K1EwkgCPOEmOV7ZOlblDO1ov5uVlMvToYFejFDMzk0T6S6a2GJg/9OphcAmlMW2 Zqmg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=h9+LNjNMvVmywd8I9foM63O5f58OmDGIXfCuEIUwK4s=; b=BWjtZqyM/77gFYLIzlExd8pIvRGHUBxjyCboAYgQ6xOLm5qwCHTI+mWjhuT8qqQfFd 2DynQw7dQuEBvMozGtSum7wg/ox7WqjoMGJQeoJy3qTTSvucupecR7TJIofdVn2k8kIh BrHCd0yl6ZYecyDVo/Db03zl11lKJk7xh3gJHqnbcc0f+QyA5mtfCL78crZ1/rjIg6q2 Q3aKwY/arKWu4QLXj9dvqayqLFq09cJfTgaTgNJwh/Xzw+SgZ96gYv+69gPfS7lAR3hX Gdrh718jsB76fRQoRKp/3xFllvKyvA/gk2dN3TtyLISsl7ksC2LjgwnRUqViSNyF/QpN Nfug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=sA6FQ9SC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a170902da8700b0018951533e11si40723776plx.278.2023.01.05.06.34.46; Thu, 05 Jan 2023 06:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=sA6FQ9SC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233905AbjAEOBz (ORCPT + 56 others); Thu, 5 Jan 2023 09:01:55 -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: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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_node *np, const char *id) "#nvmem-cell-cells", index, &cell_spec); if (ret) - return ERR_PTR(ret); + return ERR_PTR(-ENOENT); if (cell_spec.args_count > 1) return ERR_PTR(-EINVAL); -- 2.30.2