[PATCH v4 1/9] xen/dt: dt_property_read_string should return -ENODATA on !length

Stefano Stabellini posted 9 patches 2 years, 8 months ago
There is a newer version of this series
[PATCH v4 1/9] xen/dt: dt_property_read_string should return -ENODATA on !length
Posted by Stefano Stabellini 2 years, 8 months ago
From: Stefano Stabellini <stefano.stabellini@xilinx.com>

When the length is zero (pp->length == 0), dt_property_read_string
should return -ENODATA, but actually currently returns -EILSEQ because
there is no specific check for lenght == 0.

Add a check now.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
---
 xen/common/device_tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 4aae281e89..db67fb5fb4 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,
 
     if ( !pp )
         return -EINVAL;
-    if ( !pp->value )
+    if ( !pp->value || !pp->length )
         return -ENODATA;
     if ( strnlen(pp->value, pp->length) >= pp->length )
         return -EILSEQ;
-- 
2.25.1
RE: [PATCH v4 1/9] xen/dt: dt_property_read_string should return -ENODATA on !length
Posted by Henry Wang 2 years, 8 months ago
Hi Stefano,

> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of
> Stefano Stabellini
> Sent: Friday, April 1, 2022 8:39 AM
> To: xen-devel@lists.xenproject.org
> Cc: sstabellini@kernel.org; jgross@suse.com; Bertrand Marquis
> <Bertrand.Marquis@arm.com>; julien@xen.org;
> Volodymyr_Babchuk@epam.com; Stefano Stabellini
> <stefano.stabellini@xilinx.com>
> Subject: [PATCH v4 1/9] xen/dt: dt_property_read_string should return -
> ENODATA on !length
> 
> From: Stefano Stabellini <stefano.stabellini@xilinx.com>
> 
> When the length is zero (pp->length == 0), dt_property_read_string
> should return -ENODATA, but actually currently returns -EILSEQ because
> there is no specific check for lenght == 0.
> 
> Add a check now.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>

Reviewed-by: Henry Wang <Henry.Wang@arm.com>

> ---
>  xen/common/device_tree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> index 4aae281e89..db67fb5fb4 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,
> 
>      if ( !pp )
>          return -EINVAL;
> -    if ( !pp->value )
> +    if ( !pp->value || !pp->length )
>          return -ENODATA;
>      if ( strnlen(pp->value, pp->length) >= pp->length )
>          return -EILSEQ;
> --
> 2.25.1
>