drivers/reset/reset-socfpga.c:67 a10_reset_init() warn: 'data->membase' not released on lines: 67.

From: Dan Carpenter
Date: Mon Oct 26 2020 - 05:39:36 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d76913908102044f14381df865bb74df17a538cb
commit: 97c9801a15e5b0c9a20e495b2ccabf010894e74b asm-generic: don't provide ioremap for CONFIG_MMU
config: h8300-randconfig-m031-20201025 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/reset/reset-socfpga.c:67 a10_reset_init() warn: 'data->membase' not released on lines: 67.
drivers/reset/reset-socfpga.c:67 a10_reset_init() warn: 'res.start' not released on lines: 67.

vim +67 drivers/reset/reset-socfpga.c

b3ca9888f35fa69 Dinh Nguyen 2018-11-13 23 static int a10_reset_init(struct device_node *np)
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 24 {
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 25 struct reset_simple_data *data;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 26 struct resource res;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 27 resource_size_t size;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 28 int ret;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 29 u32 reg_offset = 0x10;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 30
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 31 data = kzalloc(sizeof(*data), GFP_KERNEL);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 32 if (!data)
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 33 return -ENOMEM;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 34
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 35 ret = of_address_to_resource(np, 0, &res);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 36 if (ret)
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 37 goto err_alloc;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 38
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 39 size = resource_size(&res);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 40 if (!request_mem_region(res.start, size, np->name)) {
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 41 ret = -EBUSY;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 42 goto err_alloc;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 43 }
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 44
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 45 data->membase = ioremap(res.start, size);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 46 if (!data->membase) {
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 47 ret = -ENOMEM;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 48 goto err_alloc;

Need to release the mem_region.

b3ca9888f35fa69 Dinh Nguyen 2018-11-13 49 }
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 50
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 51 if (of_property_read_u32(np, "altr,modrst-offset", &reg_offset))
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 52 pr_warn("missing altr,modrst-offset property, assuming 0x10\n");
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 53 data->membase += reg_offset;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 54
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 55 spin_lock_init(&data->lock);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 56
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 57 data->rcdev.owner = THIS_MODULE;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 58 data->rcdev.nr_resets = SOCFPGA_NR_BANKS * 32;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 59 data->rcdev.ops = &reset_simple_ops;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 60 data->rcdev.of_node = np;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 61 data->status_active_low = true;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 62
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 63 return reset_controller_register(&data->rcdev);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Need error handling if this fails.

b3ca9888f35fa69 Dinh Nguyen 2018-11-13 64
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 65 err_alloc:
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 66 kfree(data);
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 @67 return ret;
b3ca9888f35fa69 Dinh Nguyen 2018-11-13 68 };

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip