Skip to content

Commit

Permalink
drm/nouveau/disp: fix use-after-free in error handling of nouveau_con…
Browse files Browse the repository at this point in the history
…nector_create

commit 1b254b7 upstream.

We can't simply free the connector after calling drm_connector_init on it.
We need to clean up the drm side first.

It might not fix all regressions from commit 2b5d1c2
("drm/nouveau/disp: PIOR DP uses GPIO for HPD, not PMGR AUX interrupts"),
but at least it fixes a memory corruption in error handling related to
that commit.

Link: https://lore.kernel.org/lkml/20230806213107.GFZNARG6moWpFuSJ9W@fat_crate.local/
Fixes: 95983ae ("drm/nouveau/disp: add connector class")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230814144933.3956959-1-kherbst@redhat.com
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
karolherbst authored and gregkh committed Aug 23, 2023
1 parent 790c2f9 commit 3f27451
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_connector.c
Expand Up @@ -1407,8 +1407,7 @@ nouveau_connector_create(struct drm_device *dev,
ret = nvif_conn_ctor(&disp->disp, nv_connector->base.name, nv_connector->index,
&nv_connector->conn);
if (ret) {
kfree(nv_connector);
return ERR_PTR(ret);
goto drm_conn_err;
}
}

Expand Down Expand Up @@ -1470,4 +1469,9 @@ nouveau_connector_create(struct drm_device *dev,

drm_connector_register(connector);
return connector;

drm_conn_err:
drm_connector_cleanup(connector);
kfree(nv_connector);
return ERR_PTR(ret);
}

0 comments on commit 3f27451

Please sign in to comment.