Skip to content

Commit ae6a233

Browse files
Erick Archeralexdeucher
authored andcommitted
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 [1] Link: KSPP#160 [2] 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>
1 parent 08f7c68 commit ae6a233

2 files changed

Lines changed: 1 addition & 8 deletions

File tree

drivers/gpu/drm/radeon/radeon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ extern int radeon_cik_support;
132132
/* RADEON_IB_POOL_SIZE must be a power of 2 */
133133
#define RADEON_IB_POOL_SIZE 16
134134
#define RADEON_DEBUGFS_MAX_COMPONENTS 32
135-
#define RADEONFB_CONN_LIMIT 4
136135
#define RADEON_BIOS_NUM_SCRATCH 8
137136

138137
/* internal ring indices */

drivers/gpu/drm/radeon/radeon_display.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
683683
struct radeon_device *rdev = dev->dev_private;
684684
struct radeon_crtc *radeon_crtc;
685685

686-
radeon_crtc = kzalloc(sizeof(struct radeon_crtc) + (RADEONFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL);
686+
radeon_crtc = kzalloc(sizeof(*radeon_crtc), GFP_KERNEL);
687687
if (radeon_crtc == NULL)
688688
return;
689689

@@ -709,12 +709,6 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
709709
dev->mode_config.cursor_width = radeon_crtc->max_cursor_width;
710710
dev->mode_config.cursor_height = radeon_crtc->max_cursor_height;
711711

712-
#if 0
713-
radeon_crtc->mode_set.crtc = &radeon_crtc->base;
714-
radeon_crtc->mode_set.connectors = (struct drm_connector **)(radeon_crtc + 1);
715-
radeon_crtc->mode_set.num_connectors = 0;
716-
#endif
717-
718712
if (rdev->is_atom_bios && (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom))
719713
radeon_atombios_init_crtc(dev, radeon_crtc);
720714
else

0 commit comments

Comments
 (0)