Re: [PATCH] x86/mtrr: Remove unnecessary strlen() in mtrr_write()

From: Thorsten Blum
Date: Tue Feb 25 2025 - 14:17:58 EST


On 25. Feb 2025, at 14:35, Ingo Molnar wrote:
> * Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
>
>> The local variable length already holds the string length after calling
>> strncpy_from_user(). Using another local variable linlen and calling
>> strlen() is therefore unnecessary and can be removed. Remove linlen
>> and strlen() and use length instead.
>>
>> Compile-tested only.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
>> ---
>
> I see no corner-case analysis in the changelog about what may happen if
> the copy fails partially.

Hi Ingo,

I'm not sure what you mean. Why would I describe something I didn't
change? This patch only removes an unnecessary string (line) length
calculation and shouldn't affect the logic in any way.

If strncpy_from_user() fails, we immediately return length from
mtrr_write(), but my patch doesn't change this - unless I'm missing
something?

Thanks,
Thorsten