From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Mike Leach <mike.leach@linaro.org>,
linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org,
linux-kernel@vger.kernel.org
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
mathieu.poirier@linaro.org, suzuki.poulose@arm.com,
acme@kernel.org, james.clark@arm.com,
Mike Leach <mike.leach@linaro.org>
Subject: Re: [PATCH v5 3/6] coresight: configfs: Add in binary attributes to load files
Date: Sat, 24 Dec 2022 10:16:08 +0300 [thread overview]
Message-ID: <202212240621.sgsPYIdK-lkp@intel.com> (raw)
In-Reply-To: <20221219234638.3661-4-mike.leach@linaro.org>
Hi Mike,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Mike-Leach/coresight-syscfg-Extend-configfs-for-config-load/20221220-074850
base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link: https://lore.kernel.org/r/20221219234638.3661-4-mike.leach%40linaro.org
patch subject: [PATCH v5 3/6] coresight: configfs: Add in binary attributes to load files
config: arm-randconfig-m041-20221218
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.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>
smatch warnings:
drivers/hwtracing/coresight/coresight-syscfg-configfs.c:595 cscfg_cfg_load_write() warn: possible memory leak of 'load_descs'
vim +/load_descs +595 drivers/hwtracing/coresight/coresight-syscfg-configfs.c
97b8fd654556b1 Mike Leach 2022-12-19 543 static ssize_t cscfg_cfg_load_write(struct config_item *item, const void *buffer, size_t size)
97b8fd654556b1 Mike Leach 2022-12-19 544 {
97b8fd654556b1 Mike Leach 2022-12-19 545 struct cscfg_fs_load_descs *load_descs = 0;
97b8fd654556b1 Mike Leach 2022-12-19 546 struct cscfg_load_owner_info *owner_info = 0;
97b8fd654556b1 Mike Leach 2022-12-19 547 int err = 0;
97b8fd654556b1 Mike Leach 2022-12-19 548
97b8fd654556b1 Mike Leach 2022-12-19 549 /* ensure we cannot simultaneously load and unload */
97b8fd654556b1 Mike Leach 2022-12-19 550 if (!mutex_trylock(&cfs_mutex))
97b8fd654556b1 Mike Leach 2022-12-19 551 return -EBUSY;
97b8fd654556b1 Mike Leach 2022-12-19 552
97b8fd654556b1 Mike Leach 2022-12-19 553 /* check configfs load / unload ops are permitted */
97b8fd654556b1 Mike Leach 2022-12-19 554 if (!cscfg_fs_load_enabled || unload_owner_info) {
97b8fd654556b1 Mike Leach 2022-12-19 555 err = -EBUSY;
97b8fd654556b1 Mike Leach 2022-12-19 556 goto exit_unlock;
97b8fd654556b1 Mike Leach 2022-12-19 557 }
97b8fd654556b1 Mike Leach 2022-12-19 558
97b8fd654556b1 Mike Leach 2022-12-19 559 if (size > CSCFG_FILE_MAXSIZE) {
97b8fd654556b1 Mike Leach 2022-12-19 560 pr_err("cscfg: Load error - Input file too large.\n");
97b8fd654556b1 Mike Leach 2022-12-19 561 err = -EINVAL;
97b8fd654556b1 Mike Leach 2022-12-19 562 goto exit_unlock;
97b8fd654556b1 Mike Leach 2022-12-19 563 }
97b8fd654556b1 Mike Leach 2022-12-19 564
97b8fd654556b1 Mike Leach 2022-12-19 565 load_descs = kzalloc(sizeof(struct cscfg_fs_load_descs), GFP_KERNEL);
97b8fd654556b1 Mike Leach 2022-12-19 566 owner_info = kzalloc(sizeof(struct cscfg_load_owner_info), GFP_KERNEL);
97b8fd654556b1 Mike Leach 2022-12-19 567 if (!load_descs || !owner_info) {
97b8fd654556b1 Mike Leach 2022-12-19 568 err = -ENOMEM;
97b8fd654556b1 Mike Leach 2022-12-19 569 goto exit_memfree;
This exit leaks (will never happen in real life though).
97b8fd654556b1 Mike Leach 2022-12-19 570 }
97b8fd654556b1 Mike Leach 2022-12-19 571
97b8fd654556b1 Mike Leach 2022-12-19 572 owner_info->owner_handle = load_descs;
97b8fd654556b1 Mike Leach 2022-12-19 573 owner_info->type = CSCFG_OWNER_CONFIGFS;
97b8fd654556b1 Mike Leach 2022-12-19 574
97b8fd654556b1 Mike Leach 2022-12-19 575 err = cscfg_file_read_buffer(buffer, size, load_descs);
97b8fd654556b1 Mike Leach 2022-12-19 576 if (err) {
97b8fd654556b1 Mike Leach 2022-12-19 577 pr_err("cscfg: Load error - Failed to read input file.\n");
97b8fd654556b1 Mike Leach 2022-12-19 578 goto exit_memfree;
97b8fd654556b1 Mike Leach 2022-12-19 579 }
97b8fd654556b1 Mike Leach 2022-12-19 580
97b8fd654556b1 Mike Leach 2022-12-19 581 err = cscfg_load_config_sets(load_descs->config_descs, load_descs->feat_descs, owner_info);
97b8fd654556b1 Mike Leach 2022-12-19 582 if (err) {
97b8fd654556b1 Mike Leach 2022-12-19 583 pr_err("cscfg: Load error - Failed to load configuaration file.\n");
97b8fd654556b1 Mike Leach 2022-12-19 584 goto exit_memfree;
97b8fd654556b1 Mike Leach 2022-12-19 585 }
97b8fd654556b1 Mike Leach 2022-12-19 586
97b8fd654556b1 Mike Leach 2022-12-19 587 mutex_unlock(&cfs_mutex);
97b8fd654556b1 Mike Leach 2022-12-19 588 return size;
97b8fd654556b1 Mike Leach 2022-12-19 589
97b8fd654556b1 Mike Leach 2022-12-19 590 exit_memfree:
97b8fd654556b1 Mike Leach 2022-12-19 591 cscfg_configfs_free_owner_info(owner_info);
97b8fd654556b1 Mike Leach 2022-12-19 592
97b8fd654556b1 Mike Leach 2022-12-19 593 exit_unlock:
97b8fd654556b1 Mike Leach 2022-12-19 594 mutex_unlock(&cfs_mutex);
97b8fd654556b1 Mike Leach 2022-12-19 @595 return err;
97b8fd654556b1 Mike Leach 2022-12-19 596 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next prev parent reply other threads:[~2022-12-24 7:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 23:46 [PATCH v5 0/6] coresight: syscfg: Extend configfs for config load Mike Leach
2022-12-19 23:46 ` [PATCH v5 1/6] coresight: configfs: Update memory allocation / free for configfs elements Mike Leach
2022-12-19 23:46 ` [PATCH v5 2/6] coresight: configfs: Add in functionality for load via configfs Mike Leach
2022-12-19 23:46 ` [PATCH v5 3/6] coresight: configfs: Add in binary attributes to load files Mike Leach
2022-12-24 7:16 ` Dan Carpenter [this message]
2023-01-16 12:32 ` Mike Leach
2022-12-27 17:09 ` Christoph Hellwig
2023-01-16 12:36 ` Mike Leach
2022-12-19 23:46 ` [PATCH v5 4/6] coresight: configfs: Modify config files to allow userspace use Mike Leach
2022-12-27 17:10 ` Christoph Hellwig
2023-01-16 12:29 ` Mike Leach
2022-12-19 23:46 ` [PATCH v5 5/6] coresight: tools: Add config file write and reader tools Mike Leach
2022-12-19 23:46 ` [PATCH v5 6/6] Documentation: coresight: docs for config load via configfs Mike Leach
2022-12-21 3:55 ` Bagas Sanjaya
2023-01-16 12:29 ` Mike Leach
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=202212240621.sgsPYIdK-lkp@intel.com \
--to=error27@gmail.com \
--cc=acme@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=james.clark@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=suzuki.poulose@arm.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