]> Git Repo - J-linux.git/commitdiff
drm: fix null pointer dereference on null state pointer
authorColin Ian King <[email protected]>
Sat, 22 Dec 2018 13:00:46 +0000 (13:00 +0000)
committerDaniel Vetter <[email protected]>
Mon, 24 Dec 2018 10:52:43 +0000 (11:52 +0100)
In the case where state cannot be allocated, the current exit path via
label 'out' will dereference the null state pointer when calling
drm_atomic_state_put. Fix this by adding a new error exit label and
jumping to this to avoid the drm_atomic_state_put.

Detected by CoverityScan, CID#1476034 ("Dereference after null check")

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
drivers/gpu/drm/drm_damage_helper.c

index d2a1c7372f362c686993b74ce1200010962a9858..31032407254d4dab631fb863f58ee5353dbfeb08 100644 (file)
@@ -178,7 +178,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
        state = drm_atomic_state_alloc(fb->dev);
        if (!state) {
                ret = -ENOMEM;
-               goto out;
+               goto out_drop_locks;
        }
        state->acquire_ctx = &ctx;
 
@@ -238,6 +238,7 @@ out:
        kfree(rects);
        drm_atomic_state_put(state);
 
+out_drop_locks:
        drm_modeset_drop_locks(&ctx);
        drm_modeset_acquire_fini(&ctx);
 
This page took 0.057167 seconds and 4 git commands to generate.