[mcgrof-next:20211102-for-axboe-add-disk-error-handling 9/9] drivers/nvdimm/pmem.c:505:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute

From: kernel test robot
Date: Tue Nov 02 2021 - 17:03:54 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 20211102-for-axboe-add-disk-error-handling
head: 47632572dede79d2f4b7e463959b0cc975319297
commit: 47632572dede79d2f4b7e463959b0cc975319297 [9/9] block: add __must_check for *add_disk*() callers
config: x86_64-randconfig-a004-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 264d3b6d4e08401c5b50a85bd76e80b3461d77e6)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/commit/?id=47632572dede79d2f4b7e463959b0cc975319297
git remote add mcgrof-next https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git
git fetch --no-tags mcgrof-next 20211102-for-axboe-add-disk-error-handling
git checkout 47632572dede79d2f4b7e463959b0cc975319297
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64

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

All warnings (new ones prefixed by >>):

>> drivers/nvdimm/pmem.c:505:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
device_add_disk(dev, disk, pmem_attribute_groups);
^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
--
>> drivers/nvdimm/blk.c:269:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
device_add_disk(dev, disk, NULL);
^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
1 warning generated.


vim +/warn_unused_result +505 drivers/nvdimm/pmem.c

1e240e8d4a7d92 drivers/nvdimm/pmem.c Christoph Hellwig 2019-06-26 388
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 389 static int pmem_attach_disk(struct device *dev,
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 390 struct nd_namespace_common *ndns)
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 391 {
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 392 struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
f284a4f23752d0 drivers/nvdimm/pmem.c Dan Williams 2016-07-07 393 struct nd_region *nd_region = to_nd_region(dev->parent);
ce7f11a230d5b7 drivers/nvdimm/pmem.c Ross Zwisler 2018-06-06 394 int nid = dev_to_node(dev), fua;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 395 struct resource *res = &nsio->res;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 396 struct range bb_range;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 397 struct nd_pfn *nd_pfn = NULL;
c1d6e828a35df5 drivers/nvdimm/pmem.c Dan Williams 2017-01-24 398 struct dax_device *dax_dev;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 399 struct nd_pfn_sb *pfn_sb;
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 400 struct pmem_device *pmem;
468ded03c07e0f drivers/nvdimm/pmem.c Dan Williams 2016-01-15 401 struct request_queue *q;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 402 struct gendisk *disk;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 403 void *addr;
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 404 int rc;
fefc1d97fa4b5e drivers/nvdimm/pmem.c Pankaj Gupta 2019-07-05 405 unsigned long flags = 0UL;
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 406
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 407 pmem = devm_kzalloc(dev, sizeof(*pmem), GFP_KERNEL);
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 408 if (!pmem)
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 409 return -ENOMEM;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 410
8f4b01fcded2dc drivers/nvdimm/pmem.c Aneesh Kumar K.V 2019-10-31 411 rc = devm_namespace_enable(dev, ndns, nd_info_block_reserve());
8f4b01fcded2dc drivers/nvdimm/pmem.c Aneesh Kumar K.V 2019-10-31 412 if (rc)
8f4b01fcded2dc drivers/nvdimm/pmem.c Aneesh Kumar K.V 2019-10-31 413 return rc;
8f4b01fcded2dc drivers/nvdimm/pmem.c Aneesh Kumar K.V 2019-10-31 414
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 415 /* while nsio_rw_bytes is active, parse a pfn info block if present */
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 416 if (is_nd_pfn(dev)) {
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 417 nd_pfn = to_nd_pfn(dev);
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 418 rc = nvdimm_setup_pfn(nd_pfn, &pmem->pgmap);
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 419 if (rc)
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 420 return rc;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 421 }
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 422
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 423 /* we're attaching a block device, disable raw namespace access */
8f4b01fcded2dc drivers/nvdimm/pmem.c Aneesh Kumar K.V 2019-10-31 424 devm_namespace_disable(dev, ndns);
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 425
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 426 dev_set_drvdata(dev, pmem);
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 427 pmem->phys_addr = res->start;
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 428 pmem->size = resource_size(res);
0b277961f4484f drivers/nvdimm/pmem.c Dan Williams 2017-06-09 429 fua = nvdimm_has_flush(nd_region);
0b277961f4484f drivers/nvdimm/pmem.c Dan Williams 2017-06-09 430 if (!IS_ENABLED(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) || fua < 0) {
61031952f4c89d drivers/nvdimm/pmem.c Ross Zwisler 2015-06-25 431 dev_warn(dev, "unable to guarantee persistence of writes\n");
0b277961f4484f drivers/nvdimm/pmem.c Dan Williams 2017-06-09 432 fua = 0;
0b277961f4484f drivers/nvdimm/pmem.c Dan Williams 2017-06-09 433 }
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 434
947df02d255a6a drivers/nvdimm/pmem.c Dan Williams 2016-03-21 435 if (!devm_request_mem_region(dev, res->start, resource_size(res),
450c6633e874c4 drivers/nvdimm/pmem.c Dan Williams 2016-11-28 436 dev_name(&ndns->dev))) {
947df02d255a6a drivers/nvdimm/pmem.c Dan Williams 2016-03-21 437 dev_warn(dev, "could not reserve region %pR\n", res);
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 438 return -EBUSY;
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 439 }
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 440
87eb73b2ca7c1b drivers/nvdimm/pmem.c Christoph Hellwig 2021-05-21 441 disk = blk_alloc_disk(nid);
87eb73b2ca7c1b drivers/nvdimm/pmem.c Christoph Hellwig 2021-05-21 442 if (!disk)
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 443 return -ENOMEM;
87eb73b2ca7c1b drivers/nvdimm/pmem.c Christoph Hellwig 2021-05-21 444 q = disk->queue;
468ded03c07e0f drivers/nvdimm/pmem.c Dan Williams 2016-01-15 445
87eb73b2ca7c1b drivers/nvdimm/pmem.c Christoph Hellwig 2021-05-21 446 pmem->disk = disk;
a624eb520390ce drivers/nvdimm/pmem.c Dan Williams 2021-06-07 447 pmem->pgmap.owner = pmem;
34c0fd540e79fb drivers/nvdimm/pmem.c Dan Williams 2016-01-15 448 pmem->pfn_flags = PFN_DEV;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 449 if (is_nd_pfn(dev)) {
f6a55e1a3fe6b3 drivers/nvdimm/pmem.c Christoph Hellwig 2019-06-26 450 pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 451 addr = devm_memremap_pages(dev, &pmem->pgmap);
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 452 pfn_sb = nd_pfn->pfn_sb;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 453 pmem->data_offset = le64_to_cpu(pfn_sb->dataoff);
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 454 pmem->pfn_pad = resource_size(res) -
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 455 range_len(&pmem->pgmap.range);
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 456 pmem->pfn_flags |= PFN_MAP;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 457 bb_range = pmem->pgmap.range;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 458 bb_range.start += pmem->data_offset;
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 459 } else if (pmem_should_map_pages(dev)) {
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 460 pmem->pgmap.range.start = res->start;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 461 pmem->pgmap.range.end = res->end;
b7b3c01b191596 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 462 pmem->pgmap.nr_range = 1;
f6a55e1a3fe6b3 drivers/nvdimm/pmem.c Christoph Hellwig 2019-06-26 463 pmem->pgmap.type = MEMORY_DEVICE_FS_DAX;
e8d5134833006a drivers/nvdimm/pmem.c Christoph Hellwig 2017-12-29 464 addr = devm_memremap_pages(dev, &pmem->pgmap);
34c0fd540e79fb drivers/nvdimm/pmem.c Dan Williams 2016-01-15 465 pmem->pfn_flags |= PFN_MAP;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 466 bb_range = pmem->pgmap.range;
91ed7ac444ef74 drivers/nvdimm/pmem.c Dan Williams 2018-10-04 467 } else {
32b2397c1e56f3 drivers/nvdimm/pmem.c sumiyawang 2021-08-22 468 addr = devm_memremap(dev, pmem->phys_addr,
32b2397c1e56f3 drivers/nvdimm/pmem.c sumiyawang 2021-08-22 469 pmem->size, ARCH_MEMREMAP_PMEM);
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 470 bb_range.start = res->start;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 471 bb_range.end = res->end;
91ed7ac444ef74 drivers/nvdimm/pmem.c Dan Williams 2018-10-04 472 }
b36f47617f6ce7 drivers/nvdimm/pmem.c Dan Williams 2015-09-15 473
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 474 if (IS_ERR(addr))
200c79da824c97 drivers/nvdimm/pmem.c Dan Williams 2016-03-22 475 return PTR_ERR(addr);
7a9eb206663177 drivers/nvdimm/pmem.c Dan Williams 2016-06-03 476 pmem->virt_addr = addr;
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 477
ce7f11a230d5b7 drivers/nvdimm/pmem.c Ross Zwisler 2018-06-06 478 blk_queue_write_cache(q, true, fua);
5a92289f41311a drivers/nvdimm/pmem.c Dan Williams 2016-03-21 479 blk_queue_physical_block_size(q, PAGE_SIZE);
f979b13c3cc515 drivers/nvdimm/pmem.c Dan Williams 2017-06-04 480 blk_queue_logical_block_size(q, pmem_sector_size(ndns));
5a92289f41311a drivers/nvdimm/pmem.c Dan Williams 2016-03-21 481 blk_queue_max_hw_sectors(q, UINT_MAX);
8b904b5b6b58b9 drivers/nvdimm/pmem.c Bart Van Assche 2018-03-07 482 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
4557641b4c7046 drivers/nvdimm/pmem.c Ross Zwisler 2018-06-26 483 if (pmem->pfn_flags & PFN_MAP)
8b904b5b6b58b9 drivers/nvdimm/pmem.c Bart Van Assche 2018-03-07 484 blk_queue_flag_set(QUEUE_FLAG_DAX, q);
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 485
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 486 disk->fops = &pmem_fops;
6ec26b8b2d70b4 drivers/nvdimm/pmem.c Christoph Hellwig 2020-05-08 487 disk->private_data = pmem;
5212e11fde4d40 drivers/nvdimm/pmem.c Vishal Verma 2015-06-25 488 nvdimm_namespace_disk_name(ndns, disk->disk_name);
cfe30b872058f2 drivers/nvdimm/pmem.c Dan Williams 2016-03-03 489 set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
cfe30b872058f2 drivers/nvdimm/pmem.c Dan Williams 2016-03-03 490 / 512);
b95f5f4391fad6 drivers/nvdimm/pmem.c Dan Williams 2016-01-04 491 if (devm_init_badblocks(dev, &pmem->bb))
b95f5f4391fad6 drivers/nvdimm/pmem.c Dan Williams 2016-01-04 492 return -ENOMEM;
a4574f63edc6f7 drivers/nvdimm/pmem.c Dan Williams 2020-10-13 493 nvdimm_badblocks_populate(nd_region, &pmem->bb, &bb_range);
57f7f317abdd07 drivers/nvdimm/pmem.c Dan Williams 2016-01-06 494 disk->bb = &pmem->bb;
f02716db951c5e drivers/nvdimm/pmem.c Dan Williams 2016-06-15 495
fefc1d97fa4b5e drivers/nvdimm/pmem.c Pankaj Gupta 2019-07-05 496 if (is_nvdimm_sync(nd_region))
fefc1d97fa4b5e drivers/nvdimm/pmem.c Pankaj Gupta 2019-07-05 497 flags = DAXDEV_F_SYNC;
fefc1d97fa4b5e drivers/nvdimm/pmem.c Pankaj Gupta 2019-07-05 498 dax_dev = alloc_dax(pmem, disk->disk_name, &pmem_dax_ops, flags);
4e4ced93794acb drivers/nvdimm/pmem.c Vivek Goyal 2020-04-01 499 if (IS_ERR(dax_dev)) {
4e4ced93794acb drivers/nvdimm/pmem.c Vivek Goyal 2020-04-01 500 return PTR_ERR(dax_dev);
c1d6e828a35df5 drivers/nvdimm/pmem.c Dan Williams 2017-01-24 501 }
ce7f11a230d5b7 drivers/nvdimm/pmem.c Ross Zwisler 2018-06-06 502 dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
c1d6e828a35df5 drivers/nvdimm/pmem.c Dan Williams 2017-01-24 503 pmem->dax_dev = dax_dev;
6e0c90d691cd5d drivers/nvdimm/pmem.c Dan Williams 2017-06-26 504
d55174cccac2e4 drivers/nvdimm/pmem.c Christoph Hellwig 2021-09-22 @505 device_add_disk(dev, disk, pmem_attribute_groups);
c1d6e828a35df5 drivers/nvdimm/pmem.c Dan Williams 2017-01-24 506 if (devm_add_action_or_reset(dev, pmem_release_disk, pmem))
f02716db951c5e drivers/nvdimm/pmem.c Dan Williams 2016-06-15 507 return -ENOMEM;
f02716db951c5e drivers/nvdimm/pmem.c Dan Williams 2016-06-15 508
32f61d67570db0 drivers/nvdimm/pmem.c Christoph Hellwig 2020-09-01 509 nvdimm_check_and_set_ro(disk);
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 510
975750a98c2676 drivers/nvdimm/pmem.c Toshi Kani 2017-06-12 511 pmem->bb_state = sysfs_get_dirent(disk_to_dev(disk)->kobj.sd,
975750a98c2676 drivers/nvdimm/pmem.c Toshi Kani 2017-06-12 512 "badblocks");
6aa734a2f38e2e drivers/nvdimm/pmem.c Dan Williams 2017-06-30 513 if (!pmem->bb_state)
6aa734a2f38e2e drivers/nvdimm/pmem.c Dan Williams 2017-06-30 514 dev_warn(dev, "'badblocks' notification disabled\n");
975750a98c2676 drivers/nvdimm/pmem.c Toshi Kani 2017-06-12 515
8c2f7e8658df1d drivers/nvdimm/pmem.c Dan Williams 2015-06-25 516 return 0;
8c2f7e8658df1d drivers/nvdimm/pmem.c Dan Williams 2015-06-25 517 }
9e853f2313e5eb drivers/block/pmem.c Ross Zwisler 2015-04-01 518

:::::: The code at line 505 was first introduced by commit
:::::: d55174cccac2e4c2a58ff68b6b573fc0836f73bd nvdimm/pmem: fix creating the dax group

:::::: TO: Christoph Hellwig <hch@xxxxxx>
:::::: CC: Dan Williams <dan.j.williams@xxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip