]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd/display: Add NULL pointer check for kzalloc
authorHersen Wu <hersenxs.wu@amd.com>
Mon, 29 Apr 2024 20:12:21 +0000 (14:12 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 May 2024 20:18:17 +0000 (16:18 -0400)
[Why & How]
Check return pointer of kzalloc before using it.

Reviewed-by: Alex Hung <alex.hung@amd.com>
Acked-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Hersen Wu <hersenxs.wu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c

index ac93c8b9361b43502d263bdcb6e1aa091f6bb623..e5c40880b64c1878bbc1e6fa2067d8768437e8a8 100644 (file)
@@ -1273,6 +1273,8 @@ static struct hpo_dp_link_encoder *dcn401_hpo_dp_link_encoder_create(
 
        /* allocate HPO link encoder */
        hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
+       if (!hpo_dp_enc31)
+               return NULL; /* out of memory */
 
 #undef REG_STRUCT
 #define REG_STRUCT hpo_dp_link_enc_regs