drm/msm: Fix possible uninitialized access in fbdev
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 22 Feb 2023 12:37:12 +0000 (13:37 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 22 Feb 2023 16:12:36 +0000 (17:12 +0100)
Do not run drm_fb_helper_unprepare() if fbdev allocation fails. Avoids
access to an uninitialized pointer. Original bug report is at [1].

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 3fb1f62f80a1 ("drm/fb-helper: Remove drm_fb_helper_unprepare() from drm_fb_helper_fini()")
Link: https://lore.kernel.org/oe-kbuild-all/202302220810.9dymwCQ8-lkp@intel.com/
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230222123712.5049-1-tzimmermann@suse.de
drivers/gpu/drm/msm/msm_fbdev.c

index c804e5ba682af3ff9afc24de4f775fd8e7ed1042..d26aa52217ce198f1b99f4e86b6269c1053c9977 100644 (file)
@@ -136,13 +136,13 @@ static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
 struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev)
 {
        struct msm_drm_private *priv = dev->dev_private;
-       struct msm_fbdev *fbdev = NULL;
+       struct msm_fbdev *fbdev;
        struct drm_fb_helper *helper;
        int ret;
 
        fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
        if (!fbdev)
-               goto fail;
+               return NULL;
 
        helper = &fbdev->base;