Message ID | 20230105135931.2743351-1-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp313779wrt; Thu, 5 Jan 2023 06:02:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1L6ElBcC0p4QztElVB1LlYSUuICrHgSwH7GTna//vyiwvHhOi92Wqv4IM8Yx5GM/8rr7Y X-Received: by 2002:a05:6a21:999c:b0:ac:6d11:1ec7 with SMTP id ve28-20020a056a21999c00b000ac6d111ec7mr79097033pzb.17.1672927336279; Thu, 05 Jan 2023 06:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672927336; cv=none; d=google.com; s=arc-20160816; b=q2tA3QyfE9mgMr9D1SYj5uEFsY9dBRXU7ikbqKSLJ2zC/kIrab6xyq9BLB91gKp5RS 9D7J5eWG3TOzPIgkqQaFECF4VEC3uvONUazYF1bQxqrYRk0uwlb2rBK/rw0VnENyPHNd uO/5v2oVkPlrwq1QEl/LEa1d01cOd2N5zjVBRgTmqyzloohwXlYsnOQ0oocGesf8CJE9 YH7ndLbz3OBvR4/gAuwfulLZzd0Ae++/iFItrlI8EmvOtgBAMp9pPiJCdKUDQPhJ30qy oitt4c1o4ye4Pl3HiFZsYWwZipF/tK5o8aS1CmFSGMkHonNFSv5SaBRUec27evgEMBap +9TA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b188-20020a6334c5000000b00486c4b02e6esi39972473pga.188.2023.01.05.06.02.01; Thu, 05 Jan 2023 06:02:16 -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 <rfc822;tmhikaru@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <michael@walle.cc> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Alexander Stein <alexander.stein@ew.tq-group.com> Cc: Michael Walle <michael@walle.cc>, linux-kernel@vger.kernel.org, Miquel Raynal <miquel.raynal@bootlin.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754191454659484839?= X-GMAIL-MSGID: =?utf-8?q?1754191454659484839?= |
Series |
nvmem: core: return -ENOENT if nvmem cell is not found
|
|
Commit Message
Michael Walle
Jan. 5, 2023, 1:59 p.m. UTC
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 <alexander.stein@ew.tq-group.com>
Signed-off-by: Michael Walle <michael@walle.cc>
---
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(-)
Comments
Am Donnerstag, 5. Januar 2023, 14:59:31 CET schrieb Michael Walle: > 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 <alexander.stein@ew.tq-group.com> > Signed-off-by: Michael Walle <michael@walle.cc> > --- > > 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); Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
On 05/01/2023 13:59, Michael Walle wrote: > 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 <alexander.stein@ew.tq-group.com> > Signed-off-by: Michael Walle <michael@walle.cc> > --- > Applied thanks, --srini > 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);
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);