diff mbox series

[1/2] dt-bindings: thermal: correct thermal zone node name limit

Message ID 20240103142051.111717-1-krzysztof.kozlowski@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/2] dt-bindings: thermal: correct thermal zone node name limit | expand

Commit Message

Krzysztof Kozlowski Jan. 3, 2024, 2:20 p.m. UTC
Linux kernel uses thermal zone node name during registering thermal
zones and has a hard-coded limit of 20 characters, including terminating
NUL byte.  The bindings expect node names to finish with '-thermal'
which is eight bytes long, thus we have only 11 characters for the reset
of the node name, not 12.

Reported-by: Rob Herring <robh@kernel.org>
Closes: https://lore.kernel.org/all/CAL_JsqKogbT_4DPd1n94xqeHaU_J8ve5K09WOyVsRX3jxxUW3w@mail.gmail.com/
Fixes: 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rob Herring Jan. 3, 2024, 3:12 p.m. UTC | #1
On Wed, Jan 3, 2024 at 7:20 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> Linux kernel uses thermal zone node name during registering thermal
> zones and has a hard-coded limit of 20 characters, including terminating
> NUL byte.  The bindings expect node names to finish with '-thermal'
> which is eight bytes long, thus we have only 11 characters for the reset
> of the node name, not 12.
>
> Reported-by: Rob Herring <robh@kernel.org>
> Closes: https://lore.kernel.org/all/CAL_JsqKogbT_4DPd1n94xqeHaU_J8ve5K09WOyVsRX3jxxUW3w@mail.gmail.com/
> Fixes: 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
> index 4a8dabc48170..bbc883fd4044 100644
> --- a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
> +++ b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
> @@ -49,7 +49,7 @@ properties:
>        to take when the temperature crosses those thresholds.
>
>  patternProperties:
> -  "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$":
> +  "^[a-zA-Z][a-zA-Z0-9\\-]{1,11}-thermal$":

Now off by 1 instead of 2. It should be 1 starting char, 1-10 chars,
and 8 chars for "-thermal".

Can you also add a comment that this length is due to the kernel.

Rob
Krzysztof Kozlowski Jan. 3, 2024, 4:29 p.m. UTC | #2
On 03/01/2024 16:12, Rob Herring wrote:
> On Wed, Jan 3, 2024 at 7:20 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>>
>> Linux kernel uses thermal zone node name during registering thermal
>> zones and has a hard-coded limit of 20 characters, including terminating
>> NUL byte.  The bindings expect node names to finish with '-thermal'
>> which is eight bytes long, thus we have only 11 characters for the reset
>> of the node name, not 12.
>>
>> Reported-by: Rob Herring <robh@kernel.org>
>> Closes: https://lore.kernel.org/all/CAL_JsqKogbT_4DPd1n94xqeHaU_J8ve5K09WOyVsRX3jxxUW3w@mail.gmail.com/
>> Fixes: 1202a442a31f ("dt-bindings: thermal: Add yaml bindings for thermal zones")
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>>  Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
>> index 4a8dabc48170..bbc883fd4044 100644
>> --- a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
>> +++ b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
>> @@ -49,7 +49,7 @@ properties:
>>        to take when the temperature crosses those thresholds.
>>
>>  patternProperties:
>> -  "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$":
>> +  "^[a-zA-Z][a-zA-Z0-9\\-]{1,11}-thermal$":
> 
> Now off by 1 instead of 2. It should be 1 starting char, 1-10 chars,
> and 8 chars for "-thermal".

Why off by 2? prefix can be up to 11 bytes, plus 8 bytes for "-thermal"
and 1 byte for NUL. This gives 11+8+1=20, exactly the size used in Linux
kernel.

> 
> Can you also add a comment that this length is due to the kernel.

Sure

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
index 4a8dabc48170..bbc883fd4044 100644
--- a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
+++ b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml
@@ -49,7 +49,7 @@  properties:
       to take when the temperature crosses those thresholds.
 
 patternProperties:
-  "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$":
+  "^[a-zA-Z][a-zA-Z0-9\\-]{1,11}-thermal$":
     type: object
     description:
       Each thermal zone node contains information about how frequently it