From nobody Sat May 18 23:14:53 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=1648774005; cv=none; d=zohomail.com; s=zohoarc; b=cAFJpZo1HViUfRb/BbrPVO9mJq90rQ7jz7yQFAjJNgss47pywmVamFi4fnE5FXuGtNwUPXfnA0s927b5gYBZU3IMPDD6j7xj8X/tcMcOqXa+c9p6rEsG76dzpT4EmRpScCF1fHLzATa3+3tJaat2CvfiM+ovBfg3+5lO9F19lKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648774005; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1pIh1bfU16zFAMaV/27U3RWBR0J0X1r1at00U+QvMXA=; b=gWw9evWmEoBQwXL0526IBP4VbJ03Io9/bReV7+5SvpNHoP5+ZljW25VaA5qHCR/bFcy74w+lecuUBgkDynQWltNSAkeQu4aMSEDFPVYjV0eFG9j5/53e+d7DvM+cBHCfJYrGbAwPHU3EXCXLNM/kdzxLOPQQYgbHUgsoTGi7rdQ= 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 1648774005682416.1866382912208; Thu, 31 Mar 2022 17:46:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.297185.506197 (Exim 4.92) (envelope-from ) id 1na5Qj-00065z-GZ; Fri, 01 Apr 2022 00:46:21 +0000 Received: by outflank-mailman (output) from mailman id 297185.506197; Fri, 01 Apr 2022 00:46:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5Qj-00065s-D8; Fri, 01 Apr 2022 00:46:21 +0000 Received: by outflank-mailman (input) for mailman id 297185; Fri, 01 Apr 2022 00:46:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1na5Qi-00065m-7J for xen-devel@lists.xenproject.org; Fri, 01 Apr 2022 00:46:20 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2469a72b-b155-11ec-8fbc-03012f2f19d4; Fri, 01 Apr 2022 02:46:19 +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 E3654618B4; Fri, 1 Apr 2022 00:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F14CDC340EE; Fri, 1 Apr 2022 00:46:16 +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: 2469a72b-b155-11ec-8fbc-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648773977; bh=nL9OOS2GUK9hVMygYq7DQDwBRpyIvChJ46/D+IotTPY=; h=Date:From:To:cc:Subject:From; b=dqdSbn9TTy3oGM2lkkrVCTZTNSFA9ek4UshBPEPNCXQ0mfYwe4NHlcxGiXnCjpo72 ObAIdp+wQbhFKe0MQOYStUB9R+b1BQwajcC5pPP5PdjUcqzccV3o5XjvrpRSy/Hzsd C1YPAoCM/Ry463nQECOX4RinywUTHzRu/rSdAi50MNhSfmFivPT8+Quz/V/QapfDHs yIV+QcjvYwePbgwX0ieZ2762SyJrZQ9HCtgFIwzZB5tcSw1P/pykoX59k6RDpNDzSj +txUKqux8A1i0w9VNXo706Ws40D2f9I1BPG47j9EgTVRKs1BuSuKwvTOY/lAvF6/fx ZznWJ3xvaVZ6A== Date: Thu, 31 Mar 2022 17:46:16 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@ubuntu-linux-20-04-desktop 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 Subject: [PATCH] of: of_property_read_string return -ENODATA when !length Message-ID: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1648774006302100001 Content-Transfer-Encoding: quoted-printable 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 pp->length. If pp->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 diff --git a/drivers/of/property.c b/drivers/of/property.c index 8e90071de6ed..da0f02c98bb2 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -439,7 +439,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->value || !pp->length) return -ENODATA; if (strnlen(prop->value, prop->length) >=3D prop->length) return -EILSEQ;