Skip to content

Commit 1b254b7

Browse files
committed
drm/nouveau/disp: fix use-after-free in error handling of nouveau_connector_create
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
1 parent 96d3c1c commit 1b254b7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/gpu/drm/nouveau/nouveau_connector.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,8 +1408,7 @@ nouveau_connector_create(struct drm_device *dev,
14081408
ret = nvif_conn_ctor(&disp->disp, nv_connector->base.name, nv_connector->index,
14091409
&nv_connector->conn);
14101410
if (ret) {
1411-
kfree(nv_connector);
1412-
return ERR_PTR(ret);
1411+
goto drm_conn_err;
14131412
}
14141413

14151414
ret = nvif_conn_event_ctor(&nv_connector->conn, "kmsHotplug",
@@ -1426,8 +1425,7 @@ nouveau_connector_create(struct drm_device *dev,
14261425
if (ret) {
14271426
nvif_event_dtor(&nv_connector->hpd);
14281427
nvif_conn_dtor(&nv_connector->conn);
1429-
kfree(nv_connector);
1430-
return ERR_PTR(ret);
1428+
goto drm_conn_err;
14311429
}
14321430
}
14331431
}
@@ -1475,4 +1473,9 @@ nouveau_connector_create(struct drm_device *dev,
14751473

14761474
drm_connector_register(connector);
14771475
return connector;
1476+
1477+
drm_conn_err:
1478+
drm_connector_cleanup(connector);
1479+
kfree(nv_connector);
1480+
return ERR_PTR(ret);
14781481
}

0 commit comments

Comments
 (0)