lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <2fdfe9da-ce67-2495-f6c3-2610033437ad@intel.com>
Date:   Tue, 18 Jan 2022 15:33:13 +0800
From:   kernel test robot <yujie.liu@...el.com>
To:     Thomas Zimmermann <tzimmermann@...e.de>
CC:     <llvm@...ts.linux.dev>, <kbuild-all@...ts.01.org>,
        "Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
        Maxime Ripard <maxime@...no.tech>
Subject: drivers/gpu/drm/ast/ast_mode.c:1232:3: warning: Use of memory after
 it is freed [clang-analyzer-unix.Malloc]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fb3b0673b7d5b477ed104949450cd511337ba3c6
commit: 55dc449a7c60d3df5a8f0b71bbae9d5173c864f5 drm/ast: Handle failed I2C initialization gracefully
date:   4 weeks ago
config: riscv-randconfig-c006-20220113 (https://download.01.org/0day-ci/archive/20220114/202201141416.VfNXpsi5-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d1021978b8e7e35dcc30201ca1731d64b5a602a8)
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 riscv cross compiling tool for clang build
         # apt-get install binutils-riscv64-linux-gnu
         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=55dc449a7c60d3df5a8f0b71bbae9d5173c864f5
         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
         git fetch --no-tags linus master
         git checkout 55dc449a7c60d3df5a8f0b71bbae9d5173c864f5
         # save the config file to linux build tree
         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>


clang-analyzer warnings: (new ones prefixed by >>)

 >> drivers/gpu/drm/ast/ast_mode.c:1232:3: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
                    drm_connector_update_edid_property(&ast_connector->base, edid);
                    ^                                                        ~~~~
    drivers/gpu/drm/ast/ast_mode.c:1217:6: note: Assuming field 'tx_chip_type' is equal to AST_TX_DP501
            if (ast->tx_chip_type == AST_TX_DP501) {
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/ast/ast_mode.c:1217:2: note: Taking true branch
            if (ast->tx_chip_type == AST_TX_DP501) {
            ^
    drivers/gpu/drm/ast/ast_mode.c:1220:7: note: Assuming 'edid' is non-null
                    if (!edid)
                        ^~~~~
    drivers/gpu/drm/ast/ast_mode.c:1220:3: note: Taking false branch
                    if (!edid)
                    ^
    drivers/gpu/drm/ast/ast_mode.c:1224:7: note: Assuming 'flags' is false
                    if (flags)
                        ^~~~~
    drivers/gpu/drm/ast/ast_mode.c:1224:3: note: Taking false branch
                    if (flags)
                    ^
    drivers/gpu/drm/ast/ast_mode.c:1227:4: note: Memory is released
                            kfree(edid);
                            ^~~~~~~~~~~
    drivers/gpu/drm/ast/ast_mode.c:1229:7: note: 'flags' is false
            if (!flags && ast_connector->i2c)
                 ^~~~~
    drivers/gpu/drm/ast/ast_mode.c:1229:6: note: Left side of '&&' is true
            if (!flags && ast_connector->i2c)
                ^
    drivers/gpu/drm/ast/ast_mode.c:1229:16: note: Assuming field 'i2c' is null
            if (!flags && ast_connector->i2c)
                          ^~~~~~~~~~~~~~~~~~
    drivers/gpu/drm/ast/ast_mode.c:1229:2: note: Taking false branch
            if (!flags && ast_connector->i2c)
            ^
    drivers/gpu/drm/ast/ast_mode.c:1231:6: note: 'edid' is non-null
            if (edid) {
                ^~~~
    drivers/gpu/drm/ast/ast_mode.c:1231:2: note: Taking true branch
            if (edid) {
            ^
    drivers/gpu/drm/ast/ast_mode.c:1232:3: note: Use of memory after it is freed
                    drm_connector_update_edid_property(&ast_connector->base, edid);
                    ^                                                        ~~~~

vim +1232 drivers/gpu/drm/ast/ast_mode.c

312fec1405dd54 Dave Airlie       2012-02-29  1204
4961eb60f14553 Thomas Zimmermann 2019-11-07  1205  /*
4961eb60f14553 Thomas Zimmermann 2019-11-07  1206   * Connector
4961eb60f14553 Thomas Zimmermann 2019-11-07  1207   */
4961eb60f14553 Thomas Zimmermann 2019-11-07  1208
312fec1405dd54 Dave Airlie       2012-02-29  1209  static int ast_get_modes(struct drm_connector *connector)
312fec1405dd54 Dave Airlie       2012-02-29  1210  {
312fec1405dd54 Dave Airlie       2012-02-29  1211  	struct ast_connector *ast_connector = to_ast_connector(connector);
fa7dbd7688849d Thomas Zimmermann 2020-06-17  1212  	struct ast_private *ast = to_ast_private(connector->dev);
55dc449a7c60d3 Thomas Zimmermann 2021-12-06  1213  	struct edid *edid = NULL;
83c6620bae3f14 Dave Airlie       2014-03-28  1214  	bool flags = false;
55dc449a7c60d3 Thomas Zimmermann 2021-12-06  1215  	int ret;
6c9bd4432b2527 Gregory Williams  2021-07-30  1216
83c6620bae3f14 Dave Airlie       2014-03-28  1217  	if (ast->tx_chip_type == AST_TX_DP501) {
83c6620bae3f14 Dave Airlie       2014-03-28  1218  		ast->dp501_maxclk = 0xff;
83c6620bae3f14 Dave Airlie       2014-03-28  1219  		edid = kmalloc(128, GFP_KERNEL);
83c6620bae3f14 Dave Airlie       2014-03-28  1220  		if (!edid)
83c6620bae3f14 Dave Airlie       2014-03-28  1221  			return -ENOMEM;
312fec1405dd54 Dave Airlie       2012-02-29  1222
83c6620bae3f14 Dave Airlie       2014-03-28  1223  		flags = ast_dp501_read_edid(connector->dev, (u8 *)edid);
83c6620bae3f14 Dave Airlie       2014-03-28  1224  		if (flags)
83c6620bae3f14 Dave Airlie       2014-03-28  1225  			ast->dp501_maxclk = ast_get_dp501_max_clk(connector->dev);
83c6620bae3f14 Dave Airlie       2014-03-28  1226  		else
83c6620bae3f14 Dave Airlie       2014-03-28  1227  			kfree(edid);
83c6620bae3f14 Dave Airlie       2014-03-28  1228  	}
55dc449a7c60d3 Thomas Zimmermann 2021-12-06  1229  	if (!flags && ast_connector->i2c)
312fec1405dd54 Dave Airlie       2012-02-29  1230  		edid = drm_get_edid(connector, &ast_connector->i2c->adapter);
312fec1405dd54 Dave Airlie       2012-02-29  1231  	if (edid) {
c555f02371c338 Daniel Vetter     2018-07-09 @1232  		drm_connector_update_edid_property(&ast_connector->base, edid);
312fec1405dd54 Dave Airlie       2012-02-29  1233  		ret = drm_add_edid_modes(connector, edid);
993dcb05e47e35 Jani Nikula       2012-08-15  1234  		kfree(edid);
312fec1405dd54 Dave Airlie       2012-02-29  1235  		return ret;
6c9bd4432b2527 Gregory Williams  2021-07-30  1236  	}
c555f02371c338 Daniel Vetter     2018-07-09  1237  	drm_connector_update_edid_property(&ast_connector->base, NULL);
312fec1405dd54 Dave Airlie       2012-02-29  1238  	return 0;
312fec1405dd54 Dave Airlie       2012-02-29  1239  }
312fec1405dd54 Dave Airlie       2012-02-29  1240

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ