From nobody Fri May 17 05:50:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1650069059; cv=none; d=zohomail.com; s=zohoarc; b=UzHJMVJqMLCFRUjBTjygxiAE2BRzq2BfGKEWoqZN7cpCNZ6VT34VbnrpjDhkNu7mG83JVk2MD/78clOhWAYEizOfAXkVZed+HSKtM37tV4GACBiBhFlYRvwjI5vW+x+yR51xsULNWQz2EIXmf5Xtb9rEXfLLngemqNIszlGYJLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650069059; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IeCVLPaXPWjBDid2rPvhSOh0A++nAw79iyb78oYzFAk=; b=PZbC3xyPPqwrg7QlvxActLxMxvW3Lq0yLkpzAzt2zsFsOh0VipU4O+fKjhy3U6squgZkfnn6mRH91HxcP/b9HtF8hREWpYWtnbnTovu3xDU+abHsCIH8FRcvd51XdMklu8yBIBqldz+ZWuZ2ca0q7CixmNRXze1G1HX6c1ui5MQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650069059445309.37261220836615; Fri, 15 Apr 2022 17:30:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.306021.521211 (Exim 4.92) (envelope-from ) id 1nfWKi-0000qY-PU; Sat, 16 Apr 2022 00:30:36 +0000 Received: by outflank-mailman (output) from mailman id 306021.521211; Sat, 16 Apr 2022 00:30:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nfWKi-0000qR-MG; Sat, 16 Apr 2022 00:30:36 +0000 Received: by outflank-mailman (input) for mailman id 306021; Sat, 16 Apr 2022 00:30:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nfWKh-0000qJ-HF for xen-devel@lists.xenproject.org; Sat, 16 Apr 2022 00:30:35 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6d537b71-bd1c-11ec-a405-831a346695d4; Sat, 16 Apr 2022 02:30:34 +0200 (CEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2D2E622CE; Sat, 16 Apr 2022 00:30:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E029EC385A5; Sat, 16 Apr 2022 00:30:30 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6d537b71-bd1c-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650069032; bh=gQSFkzWaSCzU6UI9kfwlgCZeTrqeUZGpegqf+xzbLAQ=; h=From:To:Cc:Subject:Date:From; b=mK4bZmXVRMVSWKWTH9TVzcmpV3DnUZkbRpvjz/DD1T5ZhThWoNd9U4H+7uNIdVfJL INCK0P8w24MupU6S4o6rd8p8V9WrGLwDR0Dj/Y1EBCtyPALbRi0PRtMtjIvGjzoSE5 Af+REMEn7gGqdACUEpoqRnfM1zaKsRfoNlIftOmN8LzZTeG/GtFFliec/nLvK+TmsZ fO1XYmboB8vsYUfaKDLCUZv9zULTPj7wY+YGbxnqNtnwXpNcZOv7oXKofSjNUjrWVJ /HfMju5Ot8B0JfMq554EeAxRdXPhd6G788cbgzCAyyt4XGu9+Z21QZ7oTnUUjNouzp DFwB07UstNwnA== From: Stefano Stabellini To: robh+dt@kernel.org, frowand.list@gmail.com Cc: sstabellini@kernel.org, devicetree@vger.kernel.org, julien@xen.org, xen-devel@lists.xenproject.org, Stefano Stabellini Subject: [PATCH v2] of: of_property_read_string return -ENODATA when !length Date: Fri, 15 Apr 2022 17:30:28 -0700 Message-Id: <20220416003028.1315268-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1650069060821100001 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini When the length of the string is zero of_property_read_string should return -ENODATA according to the description of the function. However, of_property_read_string doesn't check prop->length. If prop->length is zero, return -ENODATA. Without this patch the following command in u-boot: fdt set /chosen/node property-name results in of_property_read_string returning -EILSEQ when attempting to read property-name. With this patch, it returns -ENODATA as expected. Signed-off-by: Stefano Stabellini --- Changes in v2: - use prop instead pp - drop value check - update function header documentation --- drivers/of/property.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 8e90071de6ed..84903dad96a4 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -431,6 +431,9 @@ EXPORT_SYMBOL_GPL(of_property_read_variable_u64_array); * property does not have a value, and -EILSEQ if the string is not * null-terminated within the length of the property data. * + * Note that the empty string "" has length of 1, thus -ENODATA cannot + * be interpreted as an empty string. + * * The out_string pointer is modified only if a valid string can be decode= d. */ int of_property_read_string(const struct device_node *np, const char *prop= name, @@ -439,7 +442,7 @@ int of_property_read_string(const struct device_node *n= p, const char *propname, const struct property *prop =3D of_find_property(np, propname, NULL); if (!prop) return -EINVAL; - if (!prop->value) + if (!prop->length) return -ENODATA; if (strnlen(prop->value, prop->length) >=3D prop->length) return -EILSEQ; --=20 2.25.1