]> www.infradead.org Git - users/dwmw2/linux.git/commit
drm/radeon/radeon_display: Decrease the size of allocated memory
authorErick Archer <erick.archer@outlook.com>
Sat, 30 Mar 2024 16:34:47 +0000 (17:34 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Apr 2024 02:19:39 +0000 (22:19 -0400)
commitae6a233092747e9652eb793d92f79d0820e01c6a
tree0cb8ca4050999fd65d6616c2359a646a282a17ec
parent08f7c681177b209a02740aa2c58d11fcf83d6e4d
drm/radeon/radeon_display: Decrease the size of allocated memory

This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1] [2].

In this case, the memory allocated to store RADEONFB_CONN_LIMIT pointers
to "drm_connector" structures can be avoided. This is because this
memory area is never accessed.

Also, in the kzalloc function, it is preferred to use sizeof(*pointer)
instead of sizeof(type) due to the type of the variable can change and
one needs not change the former (unlike the latter).

At the same time take advantage to remove the "#if 0" block, the code
where the removed memory area was accessed, and the RADEONFB_CONN_LIMIT
constant due to now is never used.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
Link: https://github.com/KSPP/linux/issues/160
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_display.c