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] [day] [month] [year] [list]
Message-ID: <a14ed4423ad9f0ce7bd931b33fd94810@walle.cc>
Date:   Mon, 05 Dec 2022 09:45:06 +0100
From:   Michael Walle <michael@...le.cc>
To:     Dan Carpenter <error27@...il.com>
Cc:     oe-kbuild@...ts.linux.dev, 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>, 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
Subject: Re: [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in
 nvmem_add_cells_from_of()

Am 2022-12-03 09:30, schrieb Dan Carpenter:
> 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.

Damn, what a stupid bug from me. Thanks for catching this.

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ