From nobody Fri Nov 29 02:50:56 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=1652476078; cv=none; d=zohomail.com; s=zohoarc; b=U7sIX+y8dVinU/5WBGcbcDJtxaeV+PGLzsfrimkupnBTs9uAzfQYoQrCnOpUIj8WGa4Vrn1ZGCRVRnUvhLb/OPTe4nPDT8WSfaKE9AdsMdfw5gJeBdOTJqL+YsQu5EXchSsiVZbQm0V1T2OupZ2Vnlz4sniTvzMSYM5JlRCGBnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652476078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gc5lvlMtbs/oFAC2I7x1KUoeZdOD9Xkqtp6xF/i6pLo=; b=n7wRjFdahaIAkgU3qMaZXzXZpFZkSc55bAMHzvrQgZNoMrBuV7BmD1MXAi9i/DP5DrIxgBNCG5kCDww4TW5jTi1YI37oh1o4qW0TYZg+2NnT9MZM2gHNSmboKCbafWLZXghvAZySw9RFozUYZgcn50VJuHgUnM4FmSNPk8ZyzPg= 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 1652476078171150.42002743048283; Fri, 13 May 2022 14:07:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.328776.551909 (Exim 4.92) (envelope-from ) id 1npcVc-0004XF-B1; Fri, 13 May 2022 21:07:36 +0000 Received: by outflank-mailman (output) from mailman id 328776.551909; Fri, 13 May 2022 21:07: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 1npcVc-0004X8-6z; Fri, 13 May 2022 21:07:36 +0000 Received: by outflank-mailman (input) for mailman id 328776; Fri, 13 May 2022 21:07: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 1npcVb-0004Ds-72 for xen-devel@lists.xenproject.org; Fri, 13 May 2022 21:07:35 +0000 Received: from ams.source.kernel.org (ams.source.kernel.org [2604:1380:4601:e00::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b5b83506-d300-11ec-aa76-f101dd46aeb6; Fri, 13 May 2022 23:07: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 ams.source.kernel.org (Postfix) with ESMTPS id 04C47B83132; Fri, 13 May 2022 21:07:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5388DC34100; Fri, 13 May 2022 21:07:32 +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: b5b83506-d300-11ec-aa76-f101dd46aeb6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652476052; bh=xMPekEl/+TKjYbBcl6Wf3vqDYVIUg969PFQ3M8T2yk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C+NhbuYsko/M1WS+4kF+1ImUVlPXAWyNnN6ApEm3pObIcqlTy6k26mfMW2mCd+2rW rBAPK1rmJVWyjlNl93KtRk7tP0aPkD5DYBZ7wt4oOhjQtHmK8ZjD/JzO7hw5uCMV3l 2B2KEdqo5qvCDp8MkJ19Pq3RcqOzmeyzVs5LeMTufojBeZNkCZEiXTVCyzQ1xQ/OHP SxLGP4nH3RI5QM5OFUkmFTNlS8tDwGOaUd2EyO3oLBCLOJKA4G2snjsvoEL4YruDzy Gs+vZKAf+UdsSH6WXGcsfeIFRutVq87DU3roSxZkgZx4FSxNtiYGVYAVOYPLekhzQw O0yy1IiYQ5DsA== From: Stefano Stabellini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, jgross@suse.com, Bertrand.Marquis@arm.com, julien@xen.org, Volodymyr_Babchuk@epam.com, Stefano Stabellini , Bertrand Marquis , Luca Fancellu Subject: [PATCH v7 1/7] xen/dt: of_property_read_string return -ENODATA when !length Date: Fri, 13 May 2022 14:07:24 -0700 Message-Id: <20220513210730.679871-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1652476079743100003 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. This commit is a backport of: https://lore.kernel.org/xen-devel/20220416003028.1315268-1-sstabellini@kern= el.org/ Signed-off-by: Stefano Stabellini Reviewed-by: Bertrand Marquis Reviewed-by: Luca Fancellu --- Changes in v5: - backport from Linux --- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) --- xen/common/device_tree.c | 2 +- xen/include/xen/device_tree.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 4aae281e89..0e8798bd24 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -198,7 +198,7 @@ int dt_property_read_string(const struct dt_device_node= *np, =20 if ( !pp ) return -EINVAL; - if ( !pp->value ) + if ( !pp->length ) return -ENODATA; if ( strnlen(pp->value, pp->length) >=3D pp->length ) return -EILSEQ; diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index fd6cd00b43..430a1ef445 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -451,6 +451,9 @@ static inline bool_t dt_property_read_bool(const struct= dt_device_node *np, * doest not have value, and -EILSEQ if the string is not * null-terminated with 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 dt_property_read_string(const struct dt_device_node *np, --=20 2.25.1