Re: [PATCH RFC v3 3/8] vhost-net: allow configuring extended features
From: Akihiko Odaki <hidden>
Date: 2025-06-16 08:57:53
From: Akihiko Odaki <hidden>
Date: 2025-06-16 08:57:53
On 2025/06/14 16:27, Paolo Abeni wrote:
On 6/8/25 8:16 AM, Akihiko Odaki wrote:quoted
On 2025/06/06 20:45, Paolo Abeni wrote:quoted
+ + /* Zero the trailing space provided by user-space, if any */ + if (i < count && clear_user(argp, (count - i) * sizeof(u64)))I think checking i < count is a premature optimization; it doesn't matter even if we spend a bit longer because of the lack of the check.FTR, the check is not an optimization. if `i` is greater than `count`, `clear_user` is going to try to clear almost all the memory space (the 2nd argument is an unsigned one) and will likely return with error. I think it's functionally needed.
The for loop tells i cannot be greater than count, so i < count will be false only when i == count. clear_user() does nothing except incurring small overheads in that case. i < count can be safely removed. Regards, Akihiko Odaki