Skip to contentSkip to conversation

drivers/nvme/host/core.c:4532 nvme_core_init() warn: passing zero to 'PTR_ERR'

PATCH New Dan Carpenter 1 participant 1 message Apr 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 13/13 drivers/nvme/host/core.c:4532 nvme_core_init() warn: passing zero to 'PTR_ERR'

tree:   git://git.infradead.org/users/hch/block.git nvme-generic
head:   51d5434458b4f2182f4d108c9016ac9402529ee7
commit: 51d5434458b4f2182f4d108c9016ac9402529ee7 [13/13] nvme: introduce generic per-namespace chardev
config: mips-randconfig-m031-20210408 (attached as .config)
compiler: mips64el-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
drivers/nvme/host/core.c:4532 nvme_core_init() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/nvme/host/core.c:705 nvme_configure_directives() warn: missing error code 'ret'

vim +/PTR_ERR +4532 drivers/nvme/host/core.c

893a74b7a76e6e Christoph Hellwig 2019-04-30  4486  static int __init nvme_core_init(void)
5bae7f73d378a9 Christoph Hellwig 2015-11-28  4487  {
b227c59b9b5b8a Roy Shterman      2018-01-14  4488  	int result = -ENOMEM;
5bae7f73d378a9 Christoph Hellwig 2015-11-28  4489  
811015409fd4af Christoph Hellwig 2019-04-30  4490  	_nvme_check_size();
811015409fd4af Christoph Hellwig 2019-04-30  4491  
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4492  	nvme_wq = alloc_workqueue("nvme-wq",
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4493  			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4494  	if (!nvme_wq)
b227c59b9b5b8a Roy Shterman      2018-01-14  4495  		goto out;
b227c59b9b5b8a Roy Shterman      2018-01-14  4496  
b227c59b9b5b8a Roy Shterman      2018-01-14  4497  	nvme_reset_wq = alloc_workqueue("nvme-reset-wq",
b227c59b9b5b8a Roy Shterman      2018-01-14  4498  			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
b227c59b9b5b8a Roy Shterman      2018-01-14  4499  	if (!nvme_reset_wq)
b227c59b9b5b8a Roy Shterman      2018-01-14  4500  		goto destroy_wq;
b227c59b9b5b8a Roy Shterman      2018-01-14  4501  
b227c59b9b5b8a Roy Shterman      2018-01-14  4502  	nvme_delete_wq = alloc_workqueue("nvme-delete-wq",
b227c59b9b5b8a Roy Shterman      2018-01-14  4503  			WQ_UNBOUND | WQ_MEM_RECLAIM | WQ_SYSFS, 0);
b227c59b9b5b8a Roy Shterman      2018-01-14  4504  	if (!nvme_delete_wq)
b227c59b9b5b8a Roy Shterman      2018-01-14  4505  		goto destroy_reset_wq;
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4506  
f68abd9cc00cce Javier González   2020-12-01  4507  	result = alloc_chrdev_region(&nvme_ctrl_base_chr_devt, 0,
f68abd9cc00cce Javier González   2020-12-01  4508  			NVME_MINORS, "nvme");
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4509  	if (result < 0)
b227c59b9b5b8a Roy Shterman      2018-01-14  4510  		goto destroy_delete_wq;
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4511  
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4512  	nvme_class = class_create(THIS_MODULE, "nvme");
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4513  	if (IS_ERR(nvme_class)) {
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4514  		result = PTR_ERR(nvme_class);
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4515  		goto unregister_chrdev;
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4516  	}
a42f42e5bb84d8 Sagi Grimberg     2019-09-04  4517  	nvme_class->dev_uevent = nvme_class_uevent;
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4518  
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4519  	nvme_subsys_class = class_create(THIS_MODULE, "nvme-subsystem");
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4520  	if (IS_ERR(nvme_subsys_class)) {
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4521  		result = PTR_ERR(nvme_subsys_class);
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4522  		goto destroy_class;
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4523  	}
51d5434458b4f2 Minwoo Im         2021-04-07  4524  
51d5434458b4f2 Minwoo Im         2021-04-07  4525  	result = alloc_chrdev_region(&nvme_ns_chr_devt, 0, NVME_MINORS,
51d5434458b4f2 Minwoo Im         2021-04-07  4526  				     "nvme-generic");
51d5434458b4f2 Minwoo Im         2021-04-07  4527  	if (result < 0)
51d5434458b4f2 Minwoo Im         2021-04-07  4528  		goto destroy_subsys_class;
51d5434458b4f2 Minwoo Im         2021-04-07  4529  
51d5434458b4f2 Minwoo Im         2021-04-07  4530  	nvme_ns_chr_class = class_create(THIS_MODULE, "nvme-generic");
51d5434458b4f2 Minwoo Im         2021-04-07  4531  	if (IS_ERR(nvme_ns_chr_class)) {

51d5434458b4f2 Minwoo Im 2021-04-07 @4532 result = PTR_ERR(nvme_subsys_class);

This is a copy and paste error. It should be nvme_ns_chr_class.

51d5434458b4f2 Minwoo Im         2021-04-07  4533  		goto unregister_generic_ns;
51d5434458b4f2 Minwoo Im         2021-04-07  4534  	}
51d5434458b4f2 Minwoo Im         2021-04-07  4535  
5bae7f73d378a9 Christoph Hellwig 2015-11-28  4536  	return 0;
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4537  
51d5434458b4f2 Minwoo Im         2021-04-07  4538  unregister_generic_ns:
51d5434458b4f2 Minwoo Im         2021-04-07  4539  	unregister_chrdev_region(nvme_ns_chr_devt, NVME_MINORS);
51d5434458b4f2 Minwoo Im         2021-04-07  4540  destroy_subsys_class:
51d5434458b4f2 Minwoo Im         2021-04-07  4541  	class_destroy(nvme_subsys_class);
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4542  destroy_class:
ab9e00cc72fa4c Christoph Hellwig 2017-11-09  4543  	class_destroy(nvme_class);
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4544  unregister_chrdev:
f68abd9cc00cce Javier González   2020-12-01  4545  	unregister_chrdev_region(nvme_ctrl_base_chr_devt, NVME_MINORS);
b227c59b9b5b8a Roy Shterman      2018-01-14  4546  destroy_delete_wq:
b227c59b9b5b8a Roy Shterman      2018-01-14  4547  	destroy_workqueue(nvme_delete_wq);
b227c59b9b5b8a Roy Shterman      2018-01-14  4548  destroy_reset_wq:
b227c59b9b5b8a Roy Shterman      2018-01-14  4549  	destroy_workqueue(nvme_reset_wq);
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4550  destroy_wq:
9a6327d2f25b14 Sagi Grimberg     2017-06-07  4551  	destroy_workqueue(nvme_wq);
b227c59b9b5b8a Roy Shterman      2018-01-14  4552  out:
f3ca80fc11c3af Christoph Hellwig 2015-11-28  4553  	return result;
5bae7f73d378a9 Christoph Hellwig 2015-11-28  4554  }

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

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to [email protected]