drivers/gpu/drm/omapdrm/omap_fbdev.c:235:6: warning: variable 'helper' is used uninitialized whenever 'if' condition is true

From: kernel test robot
Date: Fri Feb 24 2023 - 11:16:05 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d2980d8d826554fa6981d621e569a453787472f8
commit: 3fb1f62f80a1d249260db5ea9e22c51e52fab9ae drm/fb-helper: Remove drm_fb_helper_unprepare() from drm_fb_helper_fini()
date: 3 days ago
config: arm-randconfig-r033-20230222 (https://download.01.org/0day-ci/archive/20230225/202302250058.fYTe9aTP-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3fb1f62f80a1d249260db5ea9e22c51e52fab9ae
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3fb1f62f80a1d249260db5ea9e22c51e52fab9ae
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpu/drm/omapdrm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202302250058.fYTe9aTP-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/omapdrm/omap_fbdev.c:235:6: warning: variable 'helper' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!fbdev)
^~~~~~
drivers/gpu/drm/omapdrm/omap_fbdev.c:259:26: note: uninitialized use occurs here
drm_fb_helper_unprepare(helper);
^~~~~~
drivers/gpu/drm/omapdrm/omap_fbdev.c:235:2: note: remove the 'if' if its condition is always false
if (!fbdev)
^~~~~~~~~~~
drivers/gpu/drm/omapdrm/omap_fbdev.c:228:30: note: initialize the variable 'helper' to silence this warning
struct drm_fb_helper *helper;
^
= NULL
1 warning generated.


vim +235 drivers/gpu/drm/omapdrm/omap_fbdev.c

cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 222
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 223 /* initialize fbdev helper */
efd1f06be004a6 drivers/gpu/drm/omapdrm/omap_fbdev.c Tomi Valkeinen 2018-02-09 224 void omap_fbdev_init(struct drm_device *dev)
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 225 {
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 226 struct omap_drm_private *priv = dev->dev_private;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 227 struct omap_fbdev *fbdev = NULL;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 228 struct drm_fb_helper *helper;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 229 int ret = 0;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 230
2ee767922e1bc7 drivers/gpu/drm/omapdrm/omap_fbdev.c Laurent Pinchart 2018-03-05 231 if (!priv->num_pipes)
da77772172059e drivers/gpu/drm/omapdrm/omap_fbdev.c Peter Ujfalusi 2017-12-15 232 return;
da77772172059e drivers/gpu/drm/omapdrm/omap_fbdev.c Peter Ujfalusi 2017-12-15 233
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 234 fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
78110bb8dc4a7f drivers/staging/omapdrm/omap_fbdev.c Joe Perches 2013-02-11 @235 if (!fbdev)
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 236 goto fail;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 237
9b55b95a8eca1a drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2012-03-05 238 INIT_WORK(&fbdev->work, pan_worker);
9b55b95a8eca1a drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2012-03-05 239
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 240 helper = &fbdev->base;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 241
6c80a93be62d39 drivers/gpu/drm/omapdrm/omap_fbdev.c Thomas Zimmermann 2023-01-25 242 drm_fb_helper_prepare(dev, helper, 32, &omap_fb_helper_funcs);
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 243
2dea2d1182179e drivers/gpu/drm/omapdrm/omap_fbdev.c Pankaj Bharadiya 2020-03-05 244 ret = drm_fb_helper_init(dev, helper);
efd1f06be004a6 drivers/gpu/drm/omapdrm/omap_fbdev.c Tomi Valkeinen 2018-02-09 245 if (ret)
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 246 goto fail;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 247
6c80a93be62d39 drivers/gpu/drm/omapdrm/omap_fbdev.c Thomas Zimmermann 2023-01-25 248 ret = drm_fb_helper_initial_config(helper);
01934c2a691882 drivers/gpu/drm/omapdrm/omap_fbdev.c Thierry Reding 2014-12-19 249 if (ret)
01934c2a691882 drivers/gpu/drm/omapdrm/omap_fbdev.c Thierry Reding 2014-12-19 250 goto fini;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 251
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 252 priv->fbdev = helper;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 253
efd1f06be004a6 drivers/gpu/drm/omapdrm/omap_fbdev.c Tomi Valkeinen 2018-02-09 254 return;
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 255
01934c2a691882 drivers/gpu/drm/omapdrm/omap_fbdev.c Thierry Reding 2014-12-19 256 fini:
01934c2a691882 drivers/gpu/drm/omapdrm/omap_fbdev.c Thierry Reding 2014-12-19 257 drm_fb_helper_fini(helper);
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 258 fail:
3fb1f62f80a1d2 drivers/gpu/drm/omapdrm/omap_fbdev.c Thomas Zimmermann 2023-02-16 259 drm_fb_helper_unprepare(helper);
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 260 kfree(fbdev);
e1c1174f8d5602 drivers/gpu/drm/omapdrm/omap_fbdev.c Laurent Pinchart 2015-12-14 261
e1c1174f8d5602 drivers/gpu/drm/omapdrm/omap_fbdev.c Laurent Pinchart 2015-12-14 262 dev_warn(dev->dev, "omap_fbdev_init failed\n");
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 263 }
cd5351f4d2b1b8 drivers/staging/omapdrm/omap_fbdev.c Rob Clark 2011-11-12 264

:::::: The code at line 235 was first introduced by commit
:::::: 78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b staging: Remove unnecessary OOM messages

:::::: TO: Joe Perches <joe@xxxxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests