drm/amd/display: Add null check to dc_submit_i2c_oem
authorMartin Leung <martin.leung@amd.com>
Wed, 30 Oct 2019 18:19:30 +0000 (14:19 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 15 Jun 2022 01:38:41 +0000 (21:38 -0400)
[why]
dc_submit_i2c_oem could be called with ddc null

[how]
add null check and fail the call instead

Acked-by: Alan Liu <HaoPing.Liu@amd.com>
Signed-off-by: Martin Leung <martin.leung@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/core/dc.c

index 49339c5c723016db3167a1ff751088a3e8692abc..258322c39e9a7d6060c77d73bba5404ba069fa5f 100644 (file)
@@ -3477,10 +3477,13 @@ bool dc_submit_i2c_oem(
                struct i2c_command *cmd)
 {
        struct ddc_service *ddc = dc->res_pool->oem_device;
-       return dce_i2c_submit_command(
-               dc->res_pool,
-               ddc->ddc_pin,
-               cmd);
+       if (ddc)
+               return dce_i2c_submit_command(
+                       dc->res_pool,
+                       ddc->ddc_pin,
+                       cmd);
+
+       return false;
 }
 
 static bool link_add_remote_sink_helper(struct dc_link *dc_link, struct dc_sink *sink)