From: jsg Date: Mon, 27 Mar 2023 03:21:12 +0000 (+0000) Subject: drm: Fix potential null-ptr-deref due to drmm_mode_config_init() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=10dbcd437a13cf6139ada32e43ece3c021011609;p=openbsd drm: Fix potential null-ptr-deref due to drmm_mode_config_init() From Shang XiaoJing b14147464251f66e38fa39f0aae9780466db8610 in linux-6.1.y/6.1.16 834c23e4f798dcdc8af251b3c428ceef94741991 in mainline linux --- diff --git a/sys/dev/pci/drm/drm_mode_config.c b/sys/dev/pci/drm/drm_mode_config.c index 682478addf1..b5d597a1ea2 100644 --- a/sys/dev/pci/drm/drm_mode_config.c +++ b/sys/dev/pci/drm/drm_mode_config.c @@ -399,6 +399,8 @@ static void drm_mode_config_init_release(struct drm_device *dev, void *ptr) */ int drmm_mode_config_init(struct drm_device *dev) { + int ret; + rw_init(&dev->mode_config.mutex, "mcrwl"); drm_modeset_lock_init(&dev->mode_config.connection_mutex); rw_init(&dev->mode_config.idr_mutex, "idrlk"); @@ -420,7 +422,11 @@ int drmm_mode_config_init(struct drm_device *dev) init_llist_head(&dev->mode_config.connector_free_list); INIT_WORK(&dev->mode_config.connector_free_work, drm_connector_free_work_fn); - drm_mode_create_standard_properties(dev); + ret = drm_mode_create_standard_properties(dev); + if (ret) { + drm_mode_config_cleanup(dev); + return ret; + } /* Just to be sure */ dev->mode_config.num_fb = 0;