Re: [PATCH v4 05/14] of: Fix available buffer size calculating error in API of_device_uevent_modalias()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2025/1/11 01:48, Rob Herring wrote:
> On Thu, Jan 09, 2025 at 09:26:56PM +0800, Zijun Hu wrote:
>> From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>>
>> of_device_uevent_modalias() saves MODALIAS value from offset
>> (@env->buflen - 1), so the available buffer size should be
>> (sizeof(@env->buf) - @env->buflen + 1), but it uses the wrong
>> size (sizeof(@env->buf) - @env->buflen).
>>
>> Fix by using size of space from char '\0' inclusive which ends "MODALIAS=".
> 
> I prefer to get the printf specifier change merged rather than reviewing 
> if this is correct and doesn't introduce any new bugs. We're under 
> utilizing the buffer by 1 byte. I doubt anyone will ever hit that and 
> it's not any worse than if they exceed the correct size of the buffer.
> 

got it. you are right.

previous series v3 contains 3 patches related to MODALIAS. and i
keep this patch and drop other 2 patches in this v4 series.

my thoughts about keep this one is shown below:

1) this simple patch may record evolution history of the function.
2) you ever given suggestions about this change.
3) the issue printf specifier solution fix derives from discussion of
this change.

>>
>> Fixes: dd27dcda37f0 ("of/device: merge of_device_uevent")
>> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
>> ---
>>  drivers/of/device.c | 14 ++++++++++----
>>  1 file changed, 10 insertions(+), 4 deletions(-)





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux