* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-09-16 10:54 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-09-16 10:54 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 3999 bytes --]
BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Russ Weight <russell.h.weight@intel.com>
CC: Xu Yilun <yilun.xu@intel.com>
CC: Tom Rix <trix@redhat.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
date: 3 months ago
:::::: branch date: 2 days ago
:::::: commit date: 3 months ago
config: m68k-randconfig-m031-20220914 (https://download.01.org/0day-ci/archive/20220916/202209161807.tkd9EO6v-lkp(a)intel.com/config)
compiler: m68k-linux-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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2d Russ Weight 2022-06-06 82
154afa5c31cd2d Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2d Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2d Russ Weight 2022-06-06 85 {
154afa5c31cd2d Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2d Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2d Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2d Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2d Russ Weight 2022-06-06 90
154afa5c31cd2d Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2d Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2d Russ Weight 2022-06-06 93
154afa5c31cd2d Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2d Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2d Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2d Russ Weight 2022-06-06 97
154afa5c31cd2d Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2d Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2d Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2d Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
154afa5c31cd2d Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2d Russ Weight 2022-06-06 104 }
154afa5c31cd2d Russ Weight 2022-06-06 105
154afa5c31cd2d Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2d Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2d Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2d Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2d Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2d Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2d Russ Weight 2022-06-06 113 }
154afa5c31cd2d Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2d Russ Weight 2022-06-06 115
154afa5c31cd2d Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2d Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2d Russ Weight 2022-06-06 118
154afa5c31cd2d Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2d Russ Weight 2022-06-06 120 }
154afa5c31cd2d Russ Weight 2022-06-06 121 static DEVICE_ATTR_RO(flash_count);
154afa5c31cd2d Russ Weight 2022-06-06 122
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-09-16 6:56 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-09-16 6:56 UTC (permalink / raw)
To: kbuild, Russ Weight; +Cc: lkp, kbuild-all, linux-kernel, Xu Yilun, Tom Rix
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
config: m68k-randconfig-m031-20220914 (https://download.01.org/0day-ci/archive/20220916/202209160713.HoIRfGTB-lkp@intel.com/config)
compiler: m68k-linux-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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2d Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2d Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2d Russ Weight 2022-06-06 85 {
154afa5c31cd2d Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2d Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2d Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2d Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2d Russ Weight 2022-06-06 90
154afa5c31cd2d Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2d Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2d Russ Weight 2022-06-06 93
154afa5c31cd2d Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2d Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2d Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2d Russ Weight 2022-06-06 97
154afa5c31cd2d Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2d Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2d Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2d Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
do this check before the kmalloc()?
154afa5c31cd2d Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2d Russ Weight 2022-06-06 104 }
154afa5c31cd2d Russ Weight 2022-06-06 105
154afa5c31cd2d Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2d Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2d Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2d Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2d Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2d Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2d Russ Weight 2022-06-06 113 }
154afa5c31cd2d Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2d Russ Weight 2022-06-06 115
154afa5c31cd2d Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2d Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2d Russ Weight 2022-06-06 118
154afa5c31cd2d Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2d Russ Weight 2022-06-06 120 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-09-16 6:56 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-09-16 6:56 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3578 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
config: m68k-randconfig-m031-20220914 (https://download.01.org/0day-ci/archive/20220916/202209160713.HoIRfGTB-lkp(a)intel.com/config)
compiler: m68k-linux-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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2d Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2d Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2d Russ Weight 2022-06-06 85 {
154afa5c31cd2d Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2d Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2d Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2d Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2d Russ Weight 2022-06-06 90
154afa5c31cd2d Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2d Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2d Russ Weight 2022-06-06 93
154afa5c31cd2d Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2d Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2d Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2d Russ Weight 2022-06-06 97
154afa5c31cd2d Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2d Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2d Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2d Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
do this check before the kmalloc()?
154afa5c31cd2d Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2d Russ Weight 2022-06-06 104 }
154afa5c31cd2d Russ Weight 2022-06-06 105
154afa5c31cd2d Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2d Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2d Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2d Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2d Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2d Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2d Russ Weight 2022-06-06 113 }
154afa5c31cd2d Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2d Russ Weight 2022-06-06 115
154afa5c31cd2d Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2d Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2d Russ Weight 2022-06-06 118
154afa5c31cd2d Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2d Russ Weight 2022-06-06 120 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-09-16 6:56 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-09-15 23:11 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 3999 bytes --]
BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Russ Weight <russell.h.weight@intel.com>
CC: Xu Yilun <yilun.xu@intel.com>
CC: Tom Rix <trix@redhat.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
date: 3 months ago
:::::: branch date: 2 days ago
:::::: commit date: 3 months ago
config: m68k-randconfig-m031-20220914 (https://download.01.org/0day-ci/archive/20220916/202209160713.HoIRfGTB-lkp(a)intel.com/config)
compiler: m68k-linux-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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2d Russ Weight 2022-06-06 82
154afa5c31cd2d Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2d Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2d Russ Weight 2022-06-06 85 {
154afa5c31cd2d Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2d Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2d Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2d Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2d Russ Weight 2022-06-06 90
154afa5c31cd2d Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2d Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2d Russ Weight 2022-06-06 93
154afa5c31cd2d Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2d Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2d Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2d Russ Weight 2022-06-06 97
154afa5c31cd2d Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2d Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2d Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2d Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
154afa5c31cd2d Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2d Russ Weight 2022-06-06 104 }
154afa5c31cd2d Russ Weight 2022-06-06 105
154afa5c31cd2d Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2d Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2d Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2d Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2d Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2d Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2d Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2d Russ Weight 2022-06-06 113 }
154afa5c31cd2d Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2d Russ Weight 2022-06-06 115
154afa5c31cd2d Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2d Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2d Russ Weight 2022-06-06 118
154afa5c31cd2d Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2d Russ Weight 2022-06-06 120 }
154afa5c31cd2d Russ Weight 2022-06-06 121 static DEVICE_ATTR_RO(flash_count);
154afa5c31cd2d Russ Weight 2022-06-06 122
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-09-05 23:37 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-09-05 23:37 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4048 bytes --]
BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Russ Weight <russell.h.weight@intel.com>
CC: Xu Yilun <yilun.xu@intel.com>
CC: Tom Rix <trix@redhat.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 7e18e42e4b280c85b76967a9106a13ca61c16179
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
date: 3 months ago
:::::: branch date: 27 hours ago
:::::: commit date: 3 months ago
config: x86_64-randconfig-m031-20220905 (https://download.01.org/0day-ci/archive/20220906/202209060707.0aHHXixA-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-5) 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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2de Russ Weight 2022-06-06 82
154afa5c31cd2de Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2de Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2de Russ Weight 2022-06-06 85 {
154afa5c31cd2de Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2de Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2de Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2de Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2de Russ Weight 2022-06-06 90
154afa5c31cd2de Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2de Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2de Russ Weight 2022-06-06 93
154afa5c31cd2de Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2de Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2de Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2de Russ Weight 2022-06-06 97
154afa5c31cd2de Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2de Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2de Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2de Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2de Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
154afa5c31cd2de Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2de Russ Weight 2022-06-06 104 }
154afa5c31cd2de Russ Weight 2022-06-06 105
154afa5c31cd2de Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2de Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2de Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2de Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2de Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2de Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2de Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2de Russ Weight 2022-06-06 113 }
154afa5c31cd2de Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2de Russ Weight 2022-06-06 115
154afa5c31cd2de Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2de Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2de Russ Weight 2022-06-06 118
154afa5c31cd2de Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2de Russ Weight 2022-06-06 120 }
154afa5c31cd2de Russ Weight 2022-06-06 121 static DEVICE_ATTR_RO(flash_count);
154afa5c31cd2de Russ Weight 2022-06-06 122
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
@ 2022-08-13 17:34 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-08-13 17:34 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4087 bytes --]
BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Russ Weight <russell.h.weight@intel.com>
CC: Xu Yilun <yilun.xu@intel.com>
CC: Tom Rix <trix@redhat.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 69dac8e431af26173ca0a1ebc87054e01c585bcc
commit: 154afa5c31cd2de5e6c2c4f35eee390993ee345a fpga: m10bmc-sec: expose max10 flash update count
date: 9 weeks ago
:::::: branch date: 16 hours ago
:::::: commit date: 9 weeks ago
config: arm-randconfig-m041-20220812 (https://download.01.org/0day-ci/archive/20220814/202208140138.Xq7844Av-lkp(a)intel.com/config)
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 <dan.carpenter@oracle.com>
smatch warnings:
drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf'
vim +/flash_buf +103 drivers/fpga/intel-m10-bmc-sec-update.c
154afa5c31cd2de5 Russ Weight 2022-06-06 82
154afa5c31cd2de5 Russ Weight 2022-06-06 83 static ssize_t flash_count_show(struct device *dev,
154afa5c31cd2de5 Russ Weight 2022-06-06 84 struct device_attribute *attr, char *buf)
154afa5c31cd2de5 Russ Weight 2022-06-06 85 {
154afa5c31cd2de5 Russ Weight 2022-06-06 86 struct m10bmc_sec *sec = dev_get_drvdata(dev);
154afa5c31cd2de5 Russ Weight 2022-06-06 87 unsigned int stride, num_bits;
154afa5c31cd2de5 Russ Weight 2022-06-06 88 u8 *flash_buf;
154afa5c31cd2de5 Russ Weight 2022-06-06 89 int cnt, ret;
154afa5c31cd2de5 Russ Weight 2022-06-06 90
154afa5c31cd2de5 Russ Weight 2022-06-06 91 stride = regmap_get_reg_stride(sec->m10bmc->regmap);
154afa5c31cd2de5 Russ Weight 2022-06-06 92 num_bits = FLASH_COUNT_SIZE * 8;
154afa5c31cd2de5 Russ Weight 2022-06-06 93
154afa5c31cd2de5 Russ Weight 2022-06-06 94 flash_buf = kmalloc(FLASH_COUNT_SIZE, GFP_KERNEL);
154afa5c31cd2de5 Russ Weight 2022-06-06 95 if (!flash_buf)
154afa5c31cd2de5 Russ Weight 2022-06-06 96 return -ENOMEM;
154afa5c31cd2de5 Russ Weight 2022-06-06 97
154afa5c31cd2de5 Russ Weight 2022-06-06 98 if (FLASH_COUNT_SIZE % stride) {
154afa5c31cd2de5 Russ Weight 2022-06-06 99 dev_err(sec->dev,
154afa5c31cd2de5 Russ Weight 2022-06-06 100 "FLASH_COUNT_SIZE (0x%x) not aligned to stride (0x%x)\n",
154afa5c31cd2de5 Russ Weight 2022-06-06 101 FLASH_COUNT_SIZE, stride);
154afa5c31cd2de5 Russ Weight 2022-06-06 102 WARN_ON_ONCE(1);
154afa5c31cd2de5 Russ Weight 2022-06-06 @103 return -EINVAL;
154afa5c31cd2de5 Russ Weight 2022-06-06 104 }
154afa5c31cd2de5 Russ Weight 2022-06-06 105
154afa5c31cd2de5 Russ Weight 2022-06-06 106 ret = regmap_bulk_read(sec->m10bmc->regmap, STAGING_FLASH_COUNT,
154afa5c31cd2de5 Russ Weight 2022-06-06 107 flash_buf, FLASH_COUNT_SIZE / stride);
154afa5c31cd2de5 Russ Weight 2022-06-06 108 if (ret) {
154afa5c31cd2de5 Russ Weight 2022-06-06 109 dev_err(sec->dev,
154afa5c31cd2de5 Russ Weight 2022-06-06 110 "failed to read flash count: %x cnt %x: %d\n",
154afa5c31cd2de5 Russ Weight 2022-06-06 111 STAGING_FLASH_COUNT, FLASH_COUNT_SIZE / stride, ret);
154afa5c31cd2de5 Russ Weight 2022-06-06 112 goto exit_free;
154afa5c31cd2de5 Russ Weight 2022-06-06 113 }
154afa5c31cd2de5 Russ Weight 2022-06-06 114 cnt = num_bits - bitmap_weight((unsigned long *)flash_buf, num_bits);
154afa5c31cd2de5 Russ Weight 2022-06-06 115
154afa5c31cd2de5 Russ Weight 2022-06-06 116 exit_free:
154afa5c31cd2de5 Russ Weight 2022-06-06 117 kfree(flash_buf);
154afa5c31cd2de5 Russ Weight 2022-06-06 118
154afa5c31cd2de5 Russ Weight 2022-06-06 119 return ret ? : sysfs_emit(buf, "%u\n", cnt);
154afa5c31cd2de5 Russ Weight 2022-06-06 120 }
154afa5c31cd2de5 Russ Weight 2022-06-06 121 static DEVICE_ATTR_RO(flash_count);
154afa5c31cd2de5 Russ Weight 2022-06-06 122
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-16 10:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 10:54 drivers/fpga/intel-m10-bmc-sec-update.c:103 flash_count_show() warn: possible memory leak of 'flash_buf' kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-09-16 6:56 Dan Carpenter
2022-09-15 23:11 ` kernel test robot
2022-09-16 6:56 ` Dan Carpenter
2022-09-05 23:37 kernel test robot
2022-08-13 17:34 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.