* [linux-next:master 2808/2998] drivers/dax/bus.c:626 alloc_dev_dax_range() error: potential null dereference 'alloc'. (__request_region returns null)
@ 2020-08-25 13:39 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-08-25 13:39 UTC (permalink / raw)
To: Dan Williams; +Cc: kbuild-all, Andrew Morton, Linux Memory Management List
[-- Attachment #1: Type: text/plain, Size: 5358 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 3a00d3dfd4b68b208ecd5405e676d06c8ad6bb63
commit: 5e1c2f7ce6aae47f3f10bbe5c4d56594aa14b3b1 [2808/2998] device-dax: add dis-contiguous resource support
config: nios2-randconfig-m031-20200825 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
drivers/dax/bus.c:626 alloc_dev_dax_range() error: potential null dereference 'alloc'. (__request_region returns null)
drivers/dax/bus.c:626 alloc_dev_dax_range() error: we previously assumed 'alloc' could be null (see line 610)
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=5e1c2f7ce6aae47f3f10bbe5c4d56594aa14b3b1
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout 5e1c2f7ce6aae47f3f10bbe5c4d56594aa14b3b1
vim +/alloc +626 drivers/dax/bus.c
51cf784c42d07f Dan Williams 2017-07-12 581
6c956f1d0568d6 Dan Williams 2020-08-25 582 static int alloc_dev_dax_range(struct dev_dax *dev_dax, u64 start,
6c956f1d0568d6 Dan Williams 2020-08-25 583 resource_size_t size)
3774776cf2f571 Dan Williams 2020-08-25 584 {
3774776cf2f571 Dan Williams 2020-08-25 585 struct dax_region *dax_region = dev_dax->region;
3774776cf2f571 Dan Williams 2020-08-25 586 struct resource *res = &dax_region->res;
3774776cf2f571 Dan Williams 2020-08-25 587 struct device *dev = &dev_dax->dev;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 588 struct dev_dax_range *ranges;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 589 unsigned long pgoff = 0;
3774776cf2f571 Dan Williams 2020-08-25 590 struct resource *alloc;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 591 int i;
3774776cf2f571 Dan Williams 2020-08-25 592
3774776cf2f571 Dan Williams 2020-08-25 593 device_lock_assert(dax_region->dev);
3774776cf2f571 Dan Williams 2020-08-25 594
775775d41abcfd Dan Williams 2020-08-25 595 /* handle the seed alloc special case */
775775d41abcfd Dan Williams 2020-08-25 596 if (!size) {
5e1c2f7ce6aae4 Dan Williams 2020-08-25 597 if (dev_WARN_ONCE(dev, dev_dax->nr_range,
5e1c2f7ce6aae4 Dan Williams 2020-08-25 598 "0-size allocation must be first\n"))
5e1c2f7ce6aae4 Dan Williams 2020-08-25 599 return -EBUSY;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 600 /* nr_range == 0 is elsewhere special cased as 0-size device */
775775d41abcfd Dan Williams 2020-08-25 601 return 0;
775775d41abcfd Dan Williams 2020-08-25 602 }
775775d41abcfd Dan Williams 2020-08-25 603
5e1c2f7ce6aae4 Dan Williams 2020-08-25 604 ranges = krealloc(dev_dax->ranges, sizeof(*ranges)
5e1c2f7ce6aae4 Dan Williams 2020-08-25 605 * (dev_dax->nr_range + 1), GFP_KERNEL);
5e1c2f7ce6aae4 Dan Williams 2020-08-25 606 if (!ranges)
5e1c2f7ce6aae4 Dan Williams 2020-08-25 607 return -ENOMEM;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 608
6c956f1d0568d6 Dan Williams 2020-08-25 609 alloc = __request_region(res, start, size, dev_name(dev), 0);
5e1c2f7ce6aae4 Dan Williams 2020-08-25 @610 if (!alloc && !dev_dax->nr_range) {
5e1c2f7ce6aae4 Dan Williams 2020-08-25 611 /*
5e1c2f7ce6aae4 Dan Williams 2020-08-25 612 * If we adjusted an existing @ranges leave it alone,
5e1c2f7ce6aae4 Dan Williams 2020-08-25 613 * but if this was an empty set of ranges nothing else
5e1c2f7ce6aae4 Dan Williams 2020-08-25 614 * will release @ranges, so do it now.
5e1c2f7ce6aae4 Dan Williams 2020-08-25 615 */
5e1c2f7ce6aae4 Dan Williams 2020-08-25 616 kfree(ranges);
3774776cf2f571 Dan Williams 2020-08-25 617 return -ENOMEM;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 618 }
3774776cf2f571 Dan Williams 2020-08-25 619
5e1c2f7ce6aae4 Dan Williams 2020-08-25 620 for (i = 0; i < dev_dax->nr_range; i++)
5e1c2f7ce6aae4 Dan Williams 2020-08-25 621 pgoff += PHYS_PFN(range_len(&ranges[i].range));
5e1c2f7ce6aae4 Dan Williams 2020-08-25 622 dev_dax->ranges = ranges;
5e1c2f7ce6aae4 Dan Williams 2020-08-25 623 ranges[dev_dax->nr_range++] = (struct dev_dax_range) {
5e1c2f7ce6aae4 Dan Williams 2020-08-25 624 .pgoff = pgoff,
5e1c2f7ce6aae4 Dan Williams 2020-08-25 625 .range = {
3774776cf2f571 Dan Williams 2020-08-25 @626 .start = alloc->start,
3774776cf2f571 Dan Williams 2020-08-25 627 .end = alloc->end,
5e1c2f7ce6aae4 Dan Williams 2020-08-25 628 },
3774776cf2f571 Dan Williams 2020-08-25 629 };
3774776cf2f571 Dan Williams 2020-08-25 630
5e1c2f7ce6aae4 Dan Williams 2020-08-25 631 dev_dbg(dev, "alloc range[%d]: %pa:%pa\n", dev_dax->nr_range - 1,
5e1c2f7ce6aae4 Dan Williams 2020-08-25 632 &alloc->start, &alloc->end);
5e1c2f7ce6aae4 Dan Williams 2020-08-25 633
3774776cf2f571 Dan Williams 2020-08-25 634 return 0;
3774776cf2f571 Dan Williams 2020-08-25 635 }
3774776cf2f571 Dan Williams 2020-08-25 636
:::::: The code at line 626 was first introduced by commit
:::::: 3774776cf2f571343c360204513ccef312fa339f device-dax: add an allocation interface for device-dax instances
:::::: TO: Dan Williams <dan.j.williams@intel.com>
:::::: CC: Stephen Rothwell <sfr@canb.auug.org.au>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28384 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-25 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 13:39 [linux-next:master 2808/2998] drivers/dax/bus.c:626 alloc_dev_dax_range() error: potential null dereference 'alloc'. (__request_region returns null) kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox