devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Michael Walle <michael@walle.cc>,
	Jonathan Corbet <corbet@lwn.net>,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	Michael Walle <michael@walle.cc>
Subject: Re: [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of()
Date: Sat, 3 Dec 2022 11:30:54 +0300	[thread overview]
Message-ID: <202212030011.DQpDmsBb-lkp@intel.com> (raw)
In-Reply-To: <20221123180151.2160033-11-michael@walle.cc>

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@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.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


  reply	other threads:[~2022-12-03  8:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 18:01 [PATCH v4 00/20] nvmem: core: introduce NVMEM layouts Michael Walle
2022-11-23 18:01 ` [PATCH v4 01/20] net: add helper eth_addr_add() Michael Walle
2022-11-23 18:01 ` [PATCH v4 02/20] of: base: add of_parse_phandle_with_optional_args() Michael Walle
2022-11-23 18:01 ` [PATCH v4 03/20] of: property: make #.*-cells optional for simple props Michael Walle
2022-11-30  0:45   ` Rob Herring
2022-11-23 18:01 ` [PATCH v4 04/20] of: property: add #nvmem-cell-cells property Michael Walle
2022-11-30  0:45   ` Rob Herring
2022-11-23 18:01 ` [PATCH v4 05/20] nvmem: core: fix device node refcounting Michael Walle
2022-11-23 18:01 ` [PATCH v4 06/20] nvmem: core: add an index parameter to the cell Michael Walle
2022-11-23 18:01 ` [PATCH v4 07/20] nvmem: core: move struct nvmem_cell_info to nvmem-provider.h Michael Walle
2022-11-23 18:01 ` [PATCH v4 08/20] nvmem: core: drop the removal of the cells in nvmem_add_cells() Michael Walle
2022-11-23 18:01 ` [PATCH v4 09/20] nvmem: core: add nvmem_add_one_cell() Michael Walle
2022-11-23 18:01 ` [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of() Michael Walle
2022-12-03  8:30   ` Dan Carpenter [this message]
2022-12-05  8:45     ` Michael Walle
2022-11-23 18:01 ` [PATCH v4 11/20] nvmem: core: introduce NVMEM layouts Michael Walle
2022-11-23 18:01 ` [PATCH v4 12/20] nvmem: core: add per-cell post processing Michael Walle
2022-11-23 18:01 ` [PATCH v4 13/20] nvmem: core: allow to modify a cell before adding it Michael Walle
2022-11-23 18:01 ` [PATCH v4 14/20] nvmem: imx-ocotp: replace global post processing with layouts Michael Walle
2022-11-23 18:01 ` [PATCH v4 15/20] nvmem: cell: drop global cell_post_process Michael Walle
2022-11-23 18:01 ` [PATCH v4 16/20] nvmem: core: provide own priv pointer in post process callback Michael Walle
2022-11-23 18:01 ` [PATCH v4 17/20] nvmem: layouts: add sl28vpd layout Michael Walle
2022-11-23 18:01 ` [PATCH v4 18/20] MAINTAINERS: add myself as sl28vpd nvmem layout driver Michael Walle
2022-11-23 18:01 ` [PATCH v4 19/20] nvmem: layouts: Add ONIE tlv " Michael Walle
2022-11-23 18:01 ` [PATCH v4 20/20] MAINTAINERS: Add myself as ONIE tlv NVMEM layout maintainer Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202212030011.DQpDmsBb-lkp@intel.com \
    --to=error27@gmail.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).