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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202212030011.DQpDmsBb-lkp@intel.com>
Date:   Sat, 3 Dec 2022 11:30:54 +0300
From:   Dan Carpenter <error27@...il.com>
To:     oe-kbuild@...ts.linux.dev, Michael Walle <michael@...le.cc>,
        Jonathan Corbet <corbet@....net>,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Miquel Raynal <miquel.raynal@...tlin.com>,
        Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        Sascha Hauer <s.hauer@...gutronix.de>
Cc:     lkp@...el.com, oe-kbuild-all@...ts.linux.dev,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
        Michael Walle <michael@...le.cc>
Subject: Re: [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in
 nvmem_add_cells_from_of()

Hi Michael,

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Michael-Walle/nvmem-core-introduce-NVMEM-layouts/20221124-020554
patch link:    https://lore.kernel.org/r/20221123180151.2160033-11-michael%40walle.cc
patch subject: [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of()
config: i386-randconfig-m021
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <error27@...il.com>

New smatch warnings:
drivers/nvmem/core.c:731 nvmem_add_cells_from_of() warn: possible memory leak of 'cell'

Old smatch warnings:
drivers/nvmem/core.c:735 nvmem_add_cells_from_of() warn: possible memory leak of 'cell'

vim +/cell +731 drivers/nvmem/core.c

e888d445ac33a5 Bartosz Golaszewski 2018-09-21  689  static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  690  {
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  691  	struct device *dev = &nvmem->dev;
7ae6478b304bc0 Srinivas Kandagatla 2021-10-13  692  	struct nvmem_cell_entry *cell;
18f50dbcfd3676 Michael Walle       2022-11-23  693  	struct device_node *child;
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  694  	const __be32 *addr;
18f50dbcfd3676 Michael Walle       2022-11-23  695  	int len, ret;
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  696  
18f50dbcfd3676 Michael Walle       2022-11-23  697  	for_each_child_of_node(dev->of_node, child) {
18f50dbcfd3676 Michael Walle       2022-11-23  698  		struct nvmem_cell_info info = {0};
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  699  
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  700  		addr = of_get_property(child, "reg", &len);
0445efacec75b8 Ahmad Fatoum        2021-01-29  701  		if (!addr)
0445efacec75b8 Ahmad Fatoum        2021-01-29  702  			continue;
0445efacec75b8 Ahmad Fatoum        2021-01-29  703  		if (len < 2 * sizeof(u32)) {
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  704  			dev_err(dev, "nvmem: invalid reg on %pOF\n", child);
63879e2964bcee Christophe JAILLET  2021-06-11  705  			of_node_put(child);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  706  			return -EINVAL;
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  707  		}
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  708  
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  709  		cell = kzalloc(sizeof(*cell), GFP_KERNEL);
63879e2964bcee Christophe JAILLET  2021-06-11  710  		if (!cell) {
63879e2964bcee Christophe JAILLET  2021-06-11  711  			of_node_put(child);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  712  			return -ENOMEM;
63879e2964bcee Christophe JAILLET  2021-06-11  713  		}

Seems like "cell" is not used any more so this just leaks.

e888d445ac33a5 Bartosz Golaszewski 2018-09-21  714  
18f50dbcfd3676 Michael Walle       2022-11-23  715  		info.offset = be32_to_cpup(addr++);
18f50dbcfd3676 Michael Walle       2022-11-23  716  		info.bytes = be32_to_cpup(addr);
18f50dbcfd3676 Michael Walle       2022-11-23  717  		info.name = kasprintf(GFP_KERNEL, "%pOFn", child);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  718  
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  719  		addr = of_get_property(child, "bits", &len);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  720  		if (addr && len == (2 * sizeof(u32))) {
18f50dbcfd3676 Michael Walle       2022-11-23  721  			info.bit_offset = be32_to_cpup(addr++);
18f50dbcfd3676 Michael Walle       2022-11-23  722  			info.nbits = be32_to_cpup(addr);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  723  		}
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  724  
18f50dbcfd3676 Michael Walle       2022-11-23  725  		info.np = of_node_get(child);
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  726  
18f50dbcfd3676 Michael Walle       2022-11-23  727  		ret = nvmem_add_one_cell(nvmem, &info);
18f50dbcfd3676 Michael Walle       2022-11-23  728  		kfree(info.name);
18f50dbcfd3676 Michael Walle       2022-11-23  729  		if (ret) {
63879e2964bcee Christophe JAILLET  2021-06-11  730  			of_node_put(child);
18f50dbcfd3676 Michael Walle       2022-11-23 @731  			return ret;
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  732  		}
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  733  	}
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  734  
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  735  	return 0;
e888d445ac33a5 Bartosz Golaszewski 2018-09-21  736  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ