xen/dt: of_property_read_string return -ENODATA when !length
authorStefano Stabellini <stefano.stabellini@xilinx.com>
Fri, 13 May 2022 21:07:24 +0000 (14:07 -0700)
committerStefano Stabellini <stefano.stabellini@xilinx.com>
Tue, 24 May 2022 23:11:06 +0000 (16:11 -0700)
commitd43d2b6056fc65126e8d991a11f5dec14e51754d
tree1cce61c11e959a04c0fd59a424338e3c379c399a
parentec0cce125b8b9fccde3fa825b8ee963083b5de3b
xen/dt: of_property_read_string return -ENODATA when !length

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@kernel.org/

Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
xen/common/device_tree.c
xen/include/xen/device_tree.h