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

Thorsten Blum
2025-02-25T19:17:49Z

On 25. Feb 2025, at 14:35, Ingo Molnar wrote:
> * Thorsten Blum <thorsten.blum@linux.dev> 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@linux.dev>
>> ---
>
> 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