From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
lkp@intel.com, oe-kbuild-all@lists.linux.dev,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Luka Perkov <luka.perkov@sartura.hr>,
Robert Marko <robert.marko@sartura.hr>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] nvmem: core: Expose cells through sysfs
Date: Mon, 29 May 2023 12:14:52 +0200 [thread overview]
Message-ID: <20230529121452.3a2f33f2@xps-13> (raw)
In-Reply-To: <8c442b03-bff3-4d25-96e0-eb297e280797@kili.mountain>
Hi Dan,
dan.carpenter@linaro.org wrote on Mon, 29 May 2023 07:28:59 +0300:
> Hi Miquel,
>
> kernel test robot noticed the following build warnings:
>
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Miquel-Raynal/ABI-sysfs-nvmem-cells-Expose-cells-through-sysfs/20230523-203042
> base: char-misc/char-misc-testing
> patch link: https://lore.kernel.org/r/20230523100239.307574-3-miquel.raynal%40bootlin.com
> patch subject: [PATCH 2/2] nvmem: core: Expose cells through sysfs
> config: i386-randconfig-m021-20230525 (https://download.01.org/0day-ci/archive/20230528/202305280054.NloN5RLk-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-12) 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>
> | Closes: https://lore.kernel.org/r/202305280054.NloN5RLk-lkp@intel.com/
>
> smatch warnings:
> drivers/nvmem/core.c:380 nvmem_cell_attr_read() error: uninitialized symbol 'read_len'.
>
> vim +/read_len +380 drivers/nvmem/core.c
>
> 22c370b2163e59 Miquel Raynal 2023-05-23 328 static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry,
> 22c370b2163e59 Miquel Raynal 2023-05-23 329 const char *id, int index);
> 22c370b2163e59 Miquel Raynal 2023-05-23 330
> 22c370b2163e59 Miquel Raynal 2023-05-23 331 static ssize_t nvmem_cell_attr_read(struct file *filp, struct kobject *kobj,
> 22c370b2163e59 Miquel Raynal 2023-05-23 332 struct bin_attribute *attr, char *buf,
> 22c370b2163e59 Miquel Raynal 2023-05-23 333 loff_t pos, size_t count)
> 22c370b2163e59 Miquel Raynal 2023-05-23 334 {
> 22c370b2163e59 Miquel Raynal 2023-05-23 335 struct nvmem_cell_entry *entry;
> 22c370b2163e59 Miquel Raynal 2023-05-23 336 struct nvmem_cell *cell = NULL;
> 22c370b2163e59 Miquel Raynal 2023-05-23 337 struct nvmem_device *nvmem;
> 22c370b2163e59 Miquel Raynal 2023-05-23 338 size_t cell_sz, read_len;
> 22c370b2163e59 Miquel Raynal 2023-05-23 339 struct device *dev;
> 22c370b2163e59 Miquel Raynal 2023-05-23 340 void *content;
> 22c370b2163e59 Miquel Raynal 2023-05-23 341
> 22c370b2163e59 Miquel Raynal 2023-05-23 342 if (attr->private)
> 22c370b2163e59 Miquel Raynal 2023-05-23 343 dev = attr->private;
> 22c370b2163e59 Miquel Raynal 2023-05-23 344 else
> 22c370b2163e59 Miquel Raynal 2023-05-23 345 dev = kobj_to_dev(kobj);
> 22c370b2163e59 Miquel Raynal 2023-05-23 346 nvmem = to_nvmem_device(dev);
> 22c370b2163e59 Miquel Raynal 2023-05-23 347
> 22c370b2163e59 Miquel Raynal 2023-05-23 348 mutex_lock(&nvmem_mutex);
> 22c370b2163e59 Miquel Raynal 2023-05-23 349 list_for_each_entry(entry, &nvmem->cells, node) {
> 22c370b2163e59 Miquel Raynal 2023-05-23 350 if (strncmp(entry->name, attr->attr.name, XATTR_NAME_MAX))
> 22c370b2163e59 Miquel Raynal 2023-05-23 351 continue;
> 22c370b2163e59 Miquel Raynal 2023-05-23 352
> 22c370b2163e59 Miquel Raynal 2023-05-23 353 cell = nvmem_create_cell(entry, entry->name, 0);
> 22c370b2163e59 Miquel Raynal 2023-05-23 354 if (IS_ERR(cell)) {
> 22c370b2163e59 Miquel Raynal 2023-05-23 355 mutex_unlock(&nvmem_mutex);
> 22c370b2163e59 Miquel Raynal 2023-05-23 356 return PTR_ERR(cell);
> 22c370b2163e59 Miquel Raynal 2023-05-23 357 }
> 22c370b2163e59 Miquel Raynal 2023-05-23 358
> 22c370b2163e59 Miquel Raynal 2023-05-23 359 break;
> 22c370b2163e59 Miquel Raynal 2023-05-23 360 }
> 22c370b2163e59 Miquel Raynal 2023-05-23 361 mutex_unlock(&nvmem_mutex);
> 22c370b2163e59 Miquel Raynal 2023-05-23 362
> 22c370b2163e59 Miquel Raynal 2023-05-23 363 if (!cell)
> 22c370b2163e59 Miquel Raynal 2023-05-23 364 return -EINVAL;
> 22c370b2163e59 Miquel Raynal 2023-05-23 365
> 22c370b2163e59 Miquel Raynal 2023-05-23 366 content = nvmem_cell_read(cell, &cell_sz);
> 22c370b2163e59 Miquel Raynal 2023-05-23 367 if (IS_ERR(content)) {
> 22c370b2163e59 Miquel Raynal 2023-05-23 368 count = PTR_ERR(content);
> 22c370b2163e59 Miquel Raynal 2023-05-23 369 goto destroy_cell;
>
> read_len not initialized on this goto path.
It should be: read_len = PTR_ERR...
I will correct this in the next version, thanks for the report.
>
> 22c370b2163e59 Miquel Raynal 2023-05-23 370 }
> 22c370b2163e59 Miquel Raynal 2023-05-23 371
> 22c370b2163e59 Miquel Raynal 2023-05-23 372 read_len = min_t(unsigned int, cell_sz - pos, count);
> 22c370b2163e59 Miquel Raynal 2023-05-23 373 memcpy(buf, content + pos, read_len);
> 22c370b2163e59 Miquel Raynal 2023-05-23 374 kfree(content);
> 22c370b2163e59 Miquel Raynal 2023-05-23 375
> 22c370b2163e59 Miquel Raynal 2023-05-23 376 destroy_cell:
> 22c370b2163e59 Miquel Raynal 2023-05-23 377 kfree_const(cell->id);
> 22c370b2163e59 Miquel Raynal 2023-05-23 378 kfree(cell);
> 22c370b2163e59 Miquel Raynal 2023-05-23 379
> 22c370b2163e59 Miquel Raynal 2023-05-23 @380 return read_len;
> ^^^^^^^^^^^^^^^
>
> 22c370b2163e59 Miquel Raynal 2023-05-23 381 }
>
Thanks,
Miquèl
prev parent reply other threads:[~2023-05-29 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 10:02 [PATCH 0/2] NVMEM cells in sysfs Miquel Raynal
2023-05-23 10:02 ` [PATCH 1/2] ABI: sysfs-nvmem-cells: Expose cells through sysfs Miquel Raynal
2023-05-23 16:59 ` Greg Kroah-Hartman
2023-05-23 17:14 ` Miquel Raynal
2023-05-23 10:02 ` [PATCH 2/2] nvmem: core: " Miquel Raynal
2023-05-23 16:58 ` Greg Kroah-Hartman
2023-05-23 17:14 ` Miquel Raynal
2023-05-29 10:12 ` Miquel Raynal
2023-05-29 13:05 ` Greg Kroah-Hartman
2023-05-29 13:35 ` Miquel Raynal
2023-05-29 13:43 ` Greg Kroah-Hartman
2023-05-29 14:00 ` Miquel Raynal
2023-05-23 23:51 ` kernel test robot
2023-05-29 4:28 ` Dan Carpenter
2023-05-29 10:14 ` Miquel Raynal [this message]
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=20230529121452.3a2f33f2@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=luka.perkov@sartura.hr \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=robert.marko@sartura.hr \
--cc=srinivas.kandagatla@linaro.org \
--cc=thomas.petazzoni@bootlin.com \
/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