All of lore.kernel.org
 help / color / mirror / Atom feed
* [tobetter-linux:odroid-5.9.y 53/69] drivers/char/exynos-gpiomem.c:231 exynos_gpiomem_probe() error: we previously assumed 'inst' could be null (see line 156)
@ 2020-09-03 15:12 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-09-03 15:12 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7781 bytes --]

CC: kbuild-all(a)lists.01.org
TO: Brian Kim <brian.kim@hardkernel.com>
CC: Dongjin Kim <tobetter@gmail.com>
CC: memeka <mihailescu2m@gmail.com>
CC: Yang Deokgyu <secugyu@gmail.com>

tree:   https://github.com/tobetter/linux odroid-5.9.y
head:   2f810ed6f99dfcdb64b0df67d13f1632038ddf70
commit: 1799117f3b467a68a80ffd687a7d4d450f7bf91a [53/69] ODROID-XU4: char: exynos: add /dev/gpiomem device for rootless user GPIO access
:::::: branch date: 6 hours ago
:::::: commit date: 6 hours ago
config: i386-randconfig-m021-20200902 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
drivers/char/exynos-gpiomem.c:231 exynos_gpiomem_probe() error: we previously assumed 'inst' could be null (see line 156)
drivers/char/exynos-gpiomem.c:231 exynos_gpiomem_probe() error: dereferencing freed memory 'inst'

# https://github.com/tobetter/linux/commit/1799117f3b467a68a80ffd687a7d4d450f7bf91a
git remote add tobetter-linux https://github.com/tobetter/linux
git fetch --no-tags tobetter-linux odroid-5.9.y
git checkout 1799117f3b467a68a80ffd687a7d4d450f7bf91a
vim +/inst +231 drivers/char/exynos-gpiomem.c

1799117f3b467a6 Brian Kim 2017-01-10  144  
1799117f3b467a6 Brian Kim 2017-01-10  145  static int exynos_gpiomem_probe(struct platform_device *pdev)
1799117f3b467a6 Brian Kim 2017-01-10  146  {
1799117f3b467a6 Brian Kim 2017-01-10  147  	int err = 0;
1799117f3b467a6 Brian Kim 2017-01-10  148  	struct device *dev = &pdev->dev;
1799117f3b467a6 Brian Kim 2017-01-10  149  	struct device_node *np = dev->of_node;
1799117f3b467a6 Brian Kim 2017-01-10  150  	struct resource *res = NULL;
1799117f3b467a6 Brian Kim 2017-01-10  151  	int i = 0;
1799117f3b467a6 Brian Kim 2017-01-10  152  
1799117f3b467a6 Brian Kim 2017-01-10  153  	/* Allocate buffers and instance data */
1799117f3b467a6 Brian Kim 2017-01-10  154  	inst = kzalloc(sizeof(struct exynos_gpiomem_instance), GFP_KERNEL);
1799117f3b467a6 Brian Kim 2017-01-10  155  
1799117f3b467a6 Brian Kim 2017-01-10 @156  	if (!inst) {
1799117f3b467a6 Brian Kim 2017-01-10  157  		err = -ENOMEM;
1799117f3b467a6 Brian Kim 2017-01-10  158  		goto failed_inst_alloc;
1799117f3b467a6 Brian Kim 2017-01-10  159  	}
1799117f3b467a6 Brian Kim 2017-01-10  160  
1799117f3b467a6 Brian Kim 2017-01-10  161  	inst->dev = dev;
1799117f3b467a6 Brian Kim 2017-01-10  162  
1799117f3b467a6 Brian Kim 2017-01-10  163  	inst->gpio_area_count = of_property_count_elems_of_size(np, "reg",
1799117f3b467a6 Brian Kim 2017-01-10  164  				sizeof(u32)) / 2;
1799117f3b467a6 Brian Kim 2017-01-10  165  
1799117f3b467a6 Brian Kim 2017-01-10  166  	if (inst->gpio_area_count > 32 || inst->gpio_area_count <= 0) {
1799117f3b467a6 Brian Kim 2017-01-10  167  		dev_err(inst->dev, "failed to get gpio register area.");
1799117f3b467a6 Brian Kim 2017-01-10  168  		err = -EINVAL;
1799117f3b467a6 Brian Kim 2017-01-10  169  		goto failed_inst_alloc;
1799117f3b467a6 Brian Kim 2017-01-10  170  	}
1799117f3b467a6 Brian Kim 2017-01-10  171  
1799117f3b467a6 Brian Kim 2017-01-10  172  	dev_info(inst->dev, "Initialised: GPIO register area is %d",
1799117f3b467a6 Brian Kim 2017-01-10  173  			inst->gpio_area_count);
1799117f3b467a6 Brian Kim 2017-01-10  174  
1799117f3b467a6 Brian Kim 2017-01-10  175  	for (i = 0; i < inst->gpio_area_count; ++i) {
1799117f3b467a6 Brian Kim 2017-01-10  176  		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
1799117f3b467a6 Brian Kim 2017-01-10  177  		if (res) {
1799117f3b467a6 Brian Kim 2017-01-10  178  			inst->gpio_regs_phys[i] = res->start;
1799117f3b467a6 Brian Kim 2017-01-10  179  		} else {
1799117f3b467a6 Brian Kim 2017-01-10  180  			dev_err(inst->dev, "failed to get IO resource");
1799117f3b467a6 Brian Kim 2017-01-10  181  			err = -ENOENT;
1799117f3b467a6 Brian Kim 2017-01-10  182  			goto failed_get_resource;
1799117f3b467a6 Brian Kim 2017-01-10  183  		}
1799117f3b467a6 Brian Kim 2017-01-10  184  	}
1799117f3b467a6 Brian Kim 2017-01-10  185  
1799117f3b467a6 Brian Kim 2017-01-10  186  	/* Create character device entries */
1799117f3b467a6 Brian Kim 2017-01-10  187  	err = alloc_chrdev_region(&exynos_gpiomem_devid,
1799117f3b467a6 Brian Kim 2017-01-10  188  				  DEVICE_MINOR, 1, DEVICE_NAME);
1799117f3b467a6 Brian Kim 2017-01-10  189  	if (err != 0) {
1799117f3b467a6 Brian Kim 2017-01-10  190  		dev_err(inst->dev, "unable to allocate device number");
1799117f3b467a6 Brian Kim 2017-01-10  191  		goto failed_alloc_chrdev;
1799117f3b467a6 Brian Kim 2017-01-10  192  	}
1799117f3b467a6 Brian Kim 2017-01-10  193  	cdev_init(&exynos_gpiomem_cdev, &exynos_gpiomem_fops);
1799117f3b467a6 Brian Kim 2017-01-10  194  	exynos_gpiomem_cdev.owner = THIS_MODULE;
1799117f3b467a6 Brian Kim 2017-01-10  195  	err = cdev_add(&exynos_gpiomem_cdev, exynos_gpiomem_devid, 1);
1799117f3b467a6 Brian Kim 2017-01-10  196  	if (err != 0) {
1799117f3b467a6 Brian Kim 2017-01-10  197  		dev_err(inst->dev, "unable to register device");
1799117f3b467a6 Brian Kim 2017-01-10  198  		goto failed_cdev_add;
1799117f3b467a6 Brian Kim 2017-01-10  199  	}
1799117f3b467a6 Brian Kim 2017-01-10  200  
1799117f3b467a6 Brian Kim 2017-01-10  201  	/* Create sysfs entries */
1799117f3b467a6 Brian Kim 2017-01-10  202  	exynos_gpiomem_class = class_create(THIS_MODULE, DEVICE_NAME);
1799117f3b467a6 Brian Kim 2017-01-10  203  	err = IS_ERR(exynos_gpiomem_class);
1799117f3b467a6 Brian Kim 2017-01-10  204  	if (err)
1799117f3b467a6 Brian Kim 2017-01-10  205  		goto failed_class_create;
1799117f3b467a6 Brian Kim 2017-01-10  206  
1799117f3b467a6 Brian Kim 2017-01-10  207  	exynos_gpiomem_dev = device_create(exynos_gpiomem_class, NULL,
1799117f3b467a6 Brian Kim 2017-01-10  208  					exynos_gpiomem_devid, NULL,
1799117f3b467a6 Brian Kim 2017-01-10  209  					"gpiomem");
1799117f3b467a6 Brian Kim 2017-01-10  210  	err = IS_ERR(exynos_gpiomem_dev);
1799117f3b467a6 Brian Kim 2017-01-10  211  	if (err)
1799117f3b467a6 Brian Kim 2017-01-10  212  		goto failed_device_create;
1799117f3b467a6 Brian Kim 2017-01-10  213  
1799117f3b467a6 Brian Kim 2017-01-10  214  	for (i = 0; i < inst->gpio_area_count; ++i) {
1799117f3b467a6 Brian Kim 2017-01-10  215  		dev_info(inst->dev, "Initialised: Registers at 0x%08lx",
1799117f3b467a6 Brian Kim 2017-01-10  216  				inst->gpio_regs_phys[i]);
1799117f3b467a6 Brian Kim 2017-01-10  217  	}
1799117f3b467a6 Brian Kim 2017-01-10  218  
1799117f3b467a6 Brian Kim 2017-01-10  219  	return 0;
1799117f3b467a6 Brian Kim 2017-01-10  220  
1799117f3b467a6 Brian Kim 2017-01-10  221  failed_device_create:
1799117f3b467a6 Brian Kim 2017-01-10  222  	class_destroy(exynos_gpiomem_class);
1799117f3b467a6 Brian Kim 2017-01-10  223  failed_class_create:
1799117f3b467a6 Brian Kim 2017-01-10  224  	cdev_del(&exynos_gpiomem_cdev);
1799117f3b467a6 Brian Kim 2017-01-10  225  failed_cdev_add:
1799117f3b467a6 Brian Kim 2017-01-10  226  	unregister_chrdev_region(exynos_gpiomem_devid, 1);
1799117f3b467a6 Brian Kim 2017-01-10  227  failed_alloc_chrdev:
1799117f3b467a6 Brian Kim 2017-01-10  228  failed_get_resource:
1799117f3b467a6 Brian Kim 2017-01-10  229  	kfree(inst);
1799117f3b467a6 Brian Kim 2017-01-10  230  failed_inst_alloc:
1799117f3b467a6 Brian Kim 2017-01-10 @231  	dev_err(inst->dev, "could not load exynos_gpiomem");
1799117f3b467a6 Brian Kim 2017-01-10  232  	return err;
1799117f3b467a6 Brian Kim 2017-01-10  233  }
1799117f3b467a6 Brian Kim 2017-01-10  234  

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30723 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-03 15:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-03 15:12 [tobetter-linux:odroid-5.9.y 53/69] drivers/char/exynos-gpiomem.c:231 exynos_gpiomem_probe() error: we previously assumed 'inst' could be null (see line 156) 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.