lkml.org 
[lkml]   [2022]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 3/6] coresight: configfs: Add in binary attributes to load files
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

\
 
 \ /
  Last update: 2023-03-26 23:19    [W:0.108 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site