]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
gpu: drm: radeon: Fix a possible null-pointer dereference in radeon_connector_set_pro...
authorJia-Ju Bai <baijiaju1990@gmail.com>
Mon, 29 Jul 2019 08:36:44 +0000 (16:36 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 2 Aug 2019 15:30:38 +0000 (10:30 -0500)
In radeon_connector_set_property(), there is an if statement on line 743
to check whether connector->encoder is NULL:
    if (connector->encoder)

When connector->encoder is NULL, it is used on line 755:
    if (connector->encoder->crtc)

Thus, a possible null-pointer dereference may occur.

To fix this bug, connector->encoder is checked before being used.

This bug is found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_connectors.c

index c60d1a44d22a2c7a09705e6fdb087f972652b55c..b684cd719612b41bb90b39f842150d66e42bf453 100644 (file)
@@ -752,7 +752,7 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
 
                radeon_encoder->output_csc = val;
 
-               if (connector->encoder->crtc) {
+               if (connector->encoder && connector->encoder->crtc) {
                        struct drm_crtc *crtc  = connector->encoder->crtc;
                        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);