From b1103b12fb15d0ea9f5d84e049f5d3def20abace Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 27 Jan 2022 22:13:24 +0000 Subject: [PATCH] drm: fix null-ptr-deref in drm_dev_init_release() From Wang Hai 52e1bf49e3e25358519719284028334cb31ab543 in linux 5.15.y/5.15.17 acf20ed020ffa4d6cc8347e8d356509b95df3cbe in mainline linux --- sys/dev/pci/drm/drm_drv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 654a2a5fa50..a8060c8d39d 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -674,6 +674,7 @@ static int drm_dev_init(struct drm_device *dev, const struct drm_driver *driver, struct device *parent) { + struct inode *inode; int ret; if (!drm_core_init_complete) { @@ -710,13 +711,15 @@ static int drm_dev_init(struct drm_device *dev, if (ret) return ret; - dev->anon_inode = drm_fs_inode_new(); - if (IS_ERR(dev->anon_inode)) { - ret = PTR_ERR(dev->anon_inode); + inode = drm_fs_inode_new(); + if (IS_ERR(inode)) { + ret = PTR_ERR(inode); DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret); goto err; } + dev->anon_inode = inode; + if (drm_core_check_feature(dev, DRIVER_RENDER)) { ret = drm_minor_alloc(dev, DRM_MINOR_RENDER); if (ret) -- 2.20.1