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]
Date:   Sat, 2 Oct 2021 13:25:09 +0800
From:   kernel test robot <lkp@...el.com>
To:     Hector Martin <marcan@...can.st>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [asahilinux:pmgr/nvme-merge 1/17] drivers/mfd/syscon.c:147:1-8:
 WARNING: invalid free of devm_ allocated data

tree:   https://github.com/AsahiLinux/linux pmgr/nvme-merge
head:   22b0d5af83da25ec08f140ba00169e346f970eb7
commit: f04927fcc3313ad4efdf030d2f9a3a62ba5a78b0 [1/17] mfd/syscon: Use of_iomap() instead of ioremap()
config: i386-randconfig-c001-20211001 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

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


cocci warnings: (new ones prefixed by >>)
>> drivers/mfd/syscon.c:147:1-8: WARNING: invalid free of devm_ allocated data

vim +147 drivers/mfd/syscon.c

87d687301f3807 Dong Aisheng        2012-09-05   42  
39233b7c611248 Paul Cercueil       2019-07-24   43  static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
87d687301f3807 Dong Aisheng        2012-09-05   44  {
a00406b71c5f08 Fabrice Gasnier     2018-12-12   45  	struct clk *clk;
bdb0066df96e74 Pankaj Dubey        2014-09-30   46  	struct syscon *syscon;
bdb0066df96e74 Pankaj Dubey        2014-09-30   47  	struct regmap *regmap;
bdb0066df96e74 Pankaj Dubey        2014-09-30   48  	void __iomem *base;
db2fb60cd35d2d Damien Riegel       2015-11-30   49  	u32 reg_io_width;
bdb0066df96e74 Pankaj Dubey        2014-09-30   50  	int ret;
bdb0066df96e74 Pankaj Dubey        2014-09-30   51  	struct regmap_config syscon_config = syscon_regmap_config;
ca668f0edfae65 Philipp Zabel       2016-01-29   52  	struct resource res;
bdb0066df96e74 Pankaj Dubey        2014-09-30   53  
bdb0066df96e74 Pankaj Dubey        2014-09-30   54  	syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
bdb0066df96e74 Pankaj Dubey        2014-09-30   55  	if (!syscon)
bdb0066df96e74 Pankaj Dubey        2014-09-30   56  		return ERR_PTR(-ENOMEM);
bdb0066df96e74 Pankaj Dubey        2014-09-30   57  
ca668f0edfae65 Philipp Zabel       2016-01-29   58  	if (of_address_to_resource(np, 0, &res)) {
ca668f0edfae65 Philipp Zabel       2016-01-29   59  		ret = -ENOMEM;
ca668f0edfae65 Philipp Zabel       2016-01-29   60  		goto err_map;
ca668f0edfae65 Philipp Zabel       2016-01-29   61  	}
ca668f0edfae65 Philipp Zabel       2016-01-29   62  
f04927fcc3313a Hector Martin       2021-08-23   63  	base = of_iomap(np, 0);
bdb0066df96e74 Pankaj Dubey        2014-09-30   64  	if (!base) {
bdb0066df96e74 Pankaj Dubey        2014-09-30   65  		ret = -ENOMEM;
bdb0066df96e74 Pankaj Dubey        2014-09-30   66  		goto err_map;
bdb0066df96e74 Pankaj Dubey        2014-09-30   67  	}
bdb0066df96e74 Pankaj Dubey        2014-09-30   68  
bdb0066df96e74 Pankaj Dubey        2014-09-30   69  	/* Parse the device's DT node for an endianness specification */
bdb0066df96e74 Pankaj Dubey        2014-09-30   70  	if (of_property_read_bool(np, "big-endian"))
bdb0066df96e74 Pankaj Dubey        2014-09-30   71  		syscon_config.val_format_endian = REGMAP_ENDIAN_BIG;
bdb0066df96e74 Pankaj Dubey        2014-09-30   72  	else if (of_property_read_bool(np, "little-endian"))
bdb0066df96e74 Pankaj Dubey        2014-09-30   73  		syscon_config.val_format_endian = REGMAP_ENDIAN_LITTLE;
d29ccdb3f0e5dc Paul Burton         2016-10-14   74  	else if (of_property_read_bool(np, "native-endian"))
d29ccdb3f0e5dc Paul Burton         2016-10-14   75  		syscon_config.val_format_endian = REGMAP_ENDIAN_NATIVE;
bdb0066df96e74 Pankaj Dubey        2014-09-30   76  
db2fb60cd35d2d Damien Riegel       2015-11-30   77  	/*
db2fb60cd35d2d Damien Riegel       2015-11-30   78  	 * search for reg-io-width property in DT. If it is not provided,
db2fb60cd35d2d Damien Riegel       2015-11-30   79  	 * default to 4 bytes. regmap_init_mmio will return an error if values
db2fb60cd35d2d Damien Riegel       2015-11-30   80  	 * are invalid so there is no need to check them here.
db2fb60cd35d2d Damien Riegel       2015-11-30   81  	 */
db2fb60cd35d2d Damien Riegel       2015-11-30   82  	ret = of_property_read_u32(np, "reg-io-width", &reg_io_width);
db2fb60cd35d2d Damien Riegel       2015-11-30   83  	if (ret)
db2fb60cd35d2d Damien Riegel       2015-11-30   84  		reg_io_width = 4;
db2fb60cd35d2d Damien Riegel       2015-11-30   85  
3bafc09e779710 Baolin Wang         2017-12-25   86  	ret = of_hwspin_lock_get_id(np, 0);
3bafc09e779710 Baolin Wang         2017-12-25   87  	if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0)) {
3bafc09e779710 Baolin Wang         2017-12-25   88  		syscon_config.use_hwlock = true;
3bafc09e779710 Baolin Wang         2017-12-25   89  		syscon_config.hwlock_id = ret;
3bafc09e779710 Baolin Wang         2017-12-25   90  		syscon_config.hwlock_mode = HWLOCK_IRQSTATE;
3bafc09e779710 Baolin Wang         2017-12-25   91  	} else if (ret < 0) {
3bafc09e779710 Baolin Wang         2017-12-25   92  		switch (ret) {
3bafc09e779710 Baolin Wang         2017-12-25   93  		case -ENOENT:
3bafc09e779710 Baolin Wang         2017-12-25   94  			/* Ignore missing hwlock, it's optional. */
3bafc09e779710 Baolin Wang         2017-12-25   95  			break;
3bafc09e779710 Baolin Wang         2017-12-25   96  		default:
3bafc09e779710 Baolin Wang         2017-12-25   97  			pr_err("Failed to retrieve valid hwlock: %d\n", ret);
df561f6688fef7 Gustavo A. R. Silva 2020-08-23   98  			fallthrough;
3bafc09e779710 Baolin Wang         2017-12-25   99  		case -EPROBE_DEFER:
3bafc09e779710 Baolin Wang         2017-12-25  100  			goto err_regmap;
3bafc09e779710 Baolin Wang         2017-12-25  101  		}
3bafc09e779710 Baolin Wang         2017-12-25  102  	}
3bafc09e779710 Baolin Wang         2017-12-25  103  
e15d7f2b81d2e7 Suman Anna          2020-07-27  104  	syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@...x", np,
e15d7f2b81d2e7 Suman Anna          2020-07-27  105  				       (u64)res.start);
db2fb60cd35d2d Damien Riegel       2015-11-30  106  	syscon_config.reg_stride = reg_io_width;
db2fb60cd35d2d Damien Riegel       2015-11-30  107  	syscon_config.val_bits = reg_io_width * 8;
ca668f0edfae65 Philipp Zabel       2016-01-29  108  	syscon_config.max_register = resource_size(&res) - reg_io_width;
db2fb60cd35d2d Damien Riegel       2015-11-30  109  
bdb0066df96e74 Pankaj Dubey        2014-09-30  110  	regmap = regmap_init_mmio(NULL, base, &syscon_config);
56a1188159cb2b Limeng              2021-04-07  111  	kfree(syscon_config.name);
bdb0066df96e74 Pankaj Dubey        2014-09-30  112  	if (IS_ERR(regmap)) {
bdb0066df96e74 Pankaj Dubey        2014-09-30  113  		pr_err("regmap init failed\n");
bdb0066df96e74 Pankaj Dubey        2014-09-30  114  		ret = PTR_ERR(regmap);
bdb0066df96e74 Pankaj Dubey        2014-09-30  115  		goto err_regmap;
bdb0066df96e74 Pankaj Dubey        2014-09-30  116  	}
bdb0066df96e74 Pankaj Dubey        2014-09-30  117  
39233b7c611248 Paul Cercueil       2019-07-24  118  	if (check_clk) {
a00406b71c5f08 Fabrice Gasnier     2018-12-12  119  		clk = of_clk_get(np, 0);
a00406b71c5f08 Fabrice Gasnier     2018-12-12  120  		if (IS_ERR(clk)) {
a00406b71c5f08 Fabrice Gasnier     2018-12-12  121  			ret = PTR_ERR(clk);
a00406b71c5f08 Fabrice Gasnier     2018-12-12  122  			/* clock is optional */
a00406b71c5f08 Fabrice Gasnier     2018-12-12  123  			if (ret != -ENOENT)
a00406b71c5f08 Fabrice Gasnier     2018-12-12  124  				goto err_clk;
a00406b71c5f08 Fabrice Gasnier     2018-12-12  125  		} else {
a00406b71c5f08 Fabrice Gasnier     2018-12-12  126  			ret = regmap_mmio_attach_clk(regmap, clk);
a00406b71c5f08 Fabrice Gasnier     2018-12-12  127  			if (ret)
a00406b71c5f08 Fabrice Gasnier     2018-12-12  128  				goto err_attach;
a00406b71c5f08 Fabrice Gasnier     2018-12-12  129  		}
39233b7c611248 Paul Cercueil       2019-07-24  130  	}
a00406b71c5f08 Fabrice Gasnier     2018-12-12  131  
bdb0066df96e74 Pankaj Dubey        2014-09-30  132  	syscon->regmap = regmap;
bdb0066df96e74 Pankaj Dubey        2014-09-30  133  	syscon->np = np;
bdb0066df96e74 Pankaj Dubey        2014-09-30  134  
bdb0066df96e74 Pankaj Dubey        2014-09-30  135  	spin_lock(&syscon_list_slock);
bdb0066df96e74 Pankaj Dubey        2014-09-30  136  	list_add_tail(&syscon->list, &syscon_list);
bdb0066df96e74 Pankaj Dubey        2014-09-30  137  	spin_unlock(&syscon_list_slock);
87d687301f3807 Dong Aisheng        2012-09-05  138  
bdb0066df96e74 Pankaj Dubey        2014-09-30  139  	return syscon;
bdb0066df96e74 Pankaj Dubey        2014-09-30  140  
a00406b71c5f08 Fabrice Gasnier     2018-12-12  141  err_attach:
a00406b71c5f08 Fabrice Gasnier     2018-12-12  142  	if (!IS_ERR(clk))
a00406b71c5f08 Fabrice Gasnier     2018-12-12  143  		clk_put(clk);
a00406b71c5f08 Fabrice Gasnier     2018-12-12  144  err_clk:
a00406b71c5f08 Fabrice Gasnier     2018-12-12  145  	regmap_exit(regmap);
bdb0066df96e74 Pankaj Dubey        2014-09-30  146  err_regmap:
bdb0066df96e74 Pankaj Dubey        2014-09-30 @147  	iounmap(base);
bdb0066df96e74 Pankaj Dubey        2014-09-30  148  err_map:
bdb0066df96e74 Pankaj Dubey        2014-09-30  149  	kfree(syscon);
bdb0066df96e74 Pankaj Dubey        2014-09-30  150  	return ERR_PTR(ret);
87d687301f3807 Dong Aisheng        2012-09-05  151  }
87d687301f3807 Dong Aisheng        2012-09-05  152  

:::::: The code at line 147 was first introduced by commit
:::::: bdb0066df96e74a4002125467ebe459feff1ebef mfd: syscon: Decouple syscon interface from platform devices

:::::: TO: Pankaj Dubey <pankaj.dubey@...sung.com>
:::::: CC: Lee Jones <lee.jones@...aro.org>

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

Download attachment ".config.gz" of type "application/gzip" (37188 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ