On Sat, Feb 10, 2024 at 10:49:57AM -0600, Gustavo A. R. Silva wrote:


On 2/10/24 08:19, Erick Archer wrote:
This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1].

As the "q" variable is a pointer to "struct xe_exec_queue" and this
structure ends in a flexible array:

struct xe_exec_queue {
        [...]
        struct xe_lrc lrc[];
};

the preferred way in the kernel is to use the struct_size() helper to
do the arithmetic instead of the argument "size + size * count" in the
kzalloc() function.

This way, the code is more readable and more safer.

Link: 
https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
 [1]
Link: https://github.com/KSPP/linux/issues/160 [2]
Signed-off-by: Erick Archer <erick.arc...@gmx.com>

LGTM:

Reviewed-by: Gustavo A. R. Silva <gustavo...@kernel.org>

applied to drm-xe-next. Thanks for the patch and review.

Lucas De Marchi

Reply via email to