drm_dev_init() takes a reference to the parent device with
get_device() and releases it later through the drm_dev_init_release()
drmm action, which is only registered later in the initialization.
The check rejecting a driver that is both a compute acceleration and
a graphics driver returns -EINVAL before that action is armed, leaking
the device reference.

Drop the device reference on the feature check error path before
returning.

Fixes: 7428ff70a18a ("drm: initialize accel framework")
Cc: [email protected]
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/drm_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 675675480da4..b4c0a3b03b6f 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -729,6 +729,7 @@ static int drm_dev_init(struct drm_device *dev,
                                (drm_core_check_feature(dev, DRIVER_RENDER) ||
                                drm_core_check_feature(dev, DRIVER_MODESET))) {
                DRM_ERROR("DRM driver can't be both a compute acceleration and 
graphics driver\n");
+               put_device(dev->dev);
                return -EINVAL;
        }
 
-- 
2.34.1

Reply via email to