From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [nvdimm:libnvdimm-pending 15/22] drivers/dax/bus.c:564 devm_create_dev_dax() warn: passing zero to 'ERR_PTR'
Date: Mon, 13 Jul 2020 15:24:31 +0300 [thread overview]
Message-ID: <20200713122430.GP2549@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 7000 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git libnvdimm-pending
head: 17c5211450a8fb964757f9f51cae1dc9f973e5ee
commit: 79aac412b5c4763acdd1b7eba01aae8be5b6f22d [15/22] device-dax: Add an allocation interface for device-dax instances
config: x86_64-randconfig-m001-20200710 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 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/dax/bus.c:564 devm_create_dev_dax() warn: passing zero to 'ERR_PTR'
# https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/commit/?id=79aac412b5c4763acdd1b7eba01aae8be5b6f22d
git remote add nvdimm https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git
git remote update nvdimm
git checkout 79aac412b5c4763acdd1b7eba01aae8be5b6f22d
vim +/ERR_PTR +564 drivers/dax/bus.c
0997a0b7870fef Dan Williams 2020-01-06 481 struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
9567da0b408a25 Dan Williams 2017-07-12 482 {
0997a0b7870fef Dan Williams 2020-01-06 483 struct dax_region *dax_region = data->dax_region;
9567da0b408a25 Dan Williams 2017-07-12 484 struct device *parent = dax_region->dev;
9567da0b408a25 Dan Williams 2017-07-12 485 struct dax_device *dax_dev;
9567da0b408a25 Dan Williams 2017-07-12 486 struct dev_dax *dev_dax;
9567da0b408a25 Dan Williams 2017-07-12 487 struct inode *inode;
9567da0b408a25 Dan Williams 2017-07-12 488 struct device *dev;
79aac412b5c476 Dan Williams 2020-01-08 489 int rc;
9567da0b408a25 Dan Williams 2017-07-12 490
0997a0b7870fef Dan Williams 2020-01-06 491 if (data->id < 0)
9567da0b408a25 Dan Williams 2017-07-12 492 return ERR_PTR(-EINVAL);
9567da0b408a25 Dan Williams 2017-07-12 493
9567da0b408a25 Dan Williams 2017-07-12 494 dev_dax = kzalloc(sizeof(*dev_dax), GFP_KERNEL);
9567da0b408a25 Dan Williams 2017-07-12 495 if (!dev_dax)
9567da0b408a25 Dan Williams 2017-07-12 496 return ERR_PTR(-ENOMEM);
9567da0b408a25 Dan Williams 2017-07-12 497
79aac412b5c476 Dan Williams 2020-01-08 498 dev_dax->region = dax_region;
79aac412b5c476 Dan Williams 2020-01-08 499 dev = &dev_dax->dev;
79aac412b5c476 Dan Williams 2020-01-08 500 device_initialize(dev);
79aac412b5c476 Dan Williams 2020-01-08 501 dev_set_name(dev, "dax%d.%d", dax_region->id, data->id);
79aac412b5c476 Dan Williams 2020-01-08 502
79aac412b5c476 Dan Williams 2020-01-08 503 rc = alloc_dev_dax_range(dev_dax, data->size);
79aac412b5c476 Dan Williams 2020-01-08 504 if (rc)
79aac412b5c476 Dan Williams 2020-01-08 505 goto err_range;
79aac412b5c476 Dan Williams 2020-01-08 506
84cb8b1780cc7b Dan Williams 2020-01-06 507 if (data->pgmap) {
79aac412b5c476 Dan Williams 2020-01-08 508 dev_WARN_ONCE(parent, !is_static(dax_region),
79aac412b5c476 Dan Williams 2020-01-08 509 "custom dev_pagemap requires a static dax_region\n");
79aac412b5c476 Dan Williams 2020-01-08 510
84cb8b1780cc7b Dan Williams 2020-01-06 511 dev_dax->pgmap = kmemdup(data->pgmap,
84cb8b1780cc7b Dan Williams 2020-01-06 512 sizeof(struct dev_pagemap), GFP_KERNEL);
84cb8b1780cc7b Dan Williams 2020-01-06 513 if (!dev_dax->pgmap)
84cb8b1780cc7b Dan Williams 2020-01-06 514 goto err_pgmap;
Needs an "rc = -ENOMEM;"
84cb8b1780cc7b Dan Williams 2020-01-06 515 }
89ec9f2cfa36cc Dan Williams 2018-10-29 516
9567da0b408a25 Dan Williams 2017-07-12 517 /*
9567da0b408a25 Dan Williams 2017-07-12 518 * No 'host' or dax_operations since there is no access to this
9567da0b408a25 Dan Williams 2017-07-12 519 * device outside of mmap of the resulting character device.
9567da0b408a25 Dan Williams 2017-07-12 520 */
fefc1d97fa4b5e Pankaj Gupta 2019-07-05 521 dax_dev = alloc_dax(dev_dax, NULL, NULL, DAXDEV_F_SYNC);
4e4ced93794acb Vivek Goyal 2020-04-01 522 if (IS_ERR(dax_dev)) {
4e4ced93794acb Vivek Goyal 2020-04-01 523 rc = PTR_ERR(dax_dev);
84cb8b1780cc7b Dan Williams 2020-01-06 524 goto err_alloc_dax;
4e4ced93794acb Vivek Goyal 2020-04-01 525 }
9567da0b408a25 Dan Williams 2017-07-12 526
9567da0b408a25 Dan Williams 2017-07-12 527 /* a device_dax instance is dead while the driver is not attached */
9567da0b408a25 Dan Williams 2017-07-12 528 kill_dax(dax_dev);
9567da0b408a25 Dan Williams 2017-07-12 529
84cb8b1780cc7b Dan Williams 2020-01-06 530 /* from here on we're committed to teardown via dev_dax_release() */
9567da0b408a25 Dan Williams 2017-07-12 531 dev_dax->dax_dev = dax_dev;
8fc5c73554db0a Dan Williams 2018-11-09 532 dev_dax->target_node = dax_region->target_node;
9567da0b408a25 Dan Williams 2017-07-12 533 kref_get(&dax_region->kref);
9567da0b408a25 Dan Williams 2017-07-12 534
9567da0b408a25 Dan Williams 2017-07-12 535 inode = dax_inode(dax_dev);
9567da0b408a25 Dan Williams 2017-07-12 536 dev->devt = inode->i_rdev;
0997a0b7870fef Dan Williams 2020-01-06 537 if (data->subsys == DEV_DAX_BUS)
9567da0b408a25 Dan Williams 2017-07-12 538 dev->bus = &dax_bus_type;
730926c3b09989 Dan Williams 2017-07-16 539 else
730926c3b09989 Dan Williams 2017-07-16 540 dev->class = dax_class;
9567da0b408a25 Dan Williams 2017-07-12 541 dev->parent = parent;
770619a9510634 Dan Williams 2019-11-12 542 dev->type = &dev_dax_type;
9567da0b408a25 Dan Williams 2017-07-12 543
9567da0b408a25 Dan Williams 2017-07-12 544 rc = device_add(dev);
9567da0b408a25 Dan Williams 2017-07-12 545 if (rc) {
9567da0b408a25 Dan Williams 2017-07-12 546 kill_dev_dax(dev_dax);
9567da0b408a25 Dan Williams 2017-07-12 547 put_device(dev);
9567da0b408a25 Dan Williams 2017-07-12 548 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 549 }
9567da0b408a25 Dan Williams 2017-07-12 550
9567da0b408a25 Dan Williams 2017-07-12 551 rc = devm_add_action_or_reset(dax_region->dev, unregister_dev_dax, dev);
9567da0b408a25 Dan Williams 2017-07-12 552 if (rc)
9567da0b408a25 Dan Williams 2017-07-12 553 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 554
9567da0b408a25 Dan Williams 2017-07-12 555 return dev_dax;
79aac412b5c476 Dan Williams 2020-01-08 556
84cb8b1780cc7b Dan Williams 2020-01-06 557 err_alloc_dax:
84cb8b1780cc7b Dan Williams 2020-01-06 558 kfree(dev_dax->pgmap);
84cb8b1780cc7b Dan Williams 2020-01-06 559 err_pgmap:
79aac412b5c476 Dan Williams 2020-01-08 560 free_dev_dax_range(dev_dax);
79aac412b5c476 Dan Williams 2020-01-08 561 err_range:
9567da0b408a25 Dan Williams 2017-07-12 562 kfree(dev_dax);
9567da0b408a25 Dan Williams 2017-07-12 563
9567da0b408a25 Dan Williams 2017-07-12 @564 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 565 }
---
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: 36754 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [nvdimm:libnvdimm-pending 15/22] drivers/dax/bus.c:564 devm_create_dev_dax() warn: passing zero to 'ERR_PTR'
Date: Mon, 13 Jul 2020 15:24:31 +0300 [thread overview]
Message-ID: <20200713122430.GP2549@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 7000 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git libnvdimm-pending
head: 17c5211450a8fb964757f9f51cae1dc9f973e5ee
commit: 79aac412b5c4763acdd1b7eba01aae8be5b6f22d [15/22] device-dax: Add an allocation interface for device-dax instances
config: x86_64-randconfig-m001-20200710 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 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/dax/bus.c:564 devm_create_dev_dax() warn: passing zero to 'ERR_PTR'
# https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/commit/?id=79aac412b5c4763acdd1b7eba01aae8be5b6f22d
git remote add nvdimm https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git
git remote update nvdimm
git checkout 79aac412b5c4763acdd1b7eba01aae8be5b6f22d
vim +/ERR_PTR +564 drivers/dax/bus.c
0997a0b7870fef Dan Williams 2020-01-06 481 struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data)
9567da0b408a25 Dan Williams 2017-07-12 482 {
0997a0b7870fef Dan Williams 2020-01-06 483 struct dax_region *dax_region = data->dax_region;
9567da0b408a25 Dan Williams 2017-07-12 484 struct device *parent = dax_region->dev;
9567da0b408a25 Dan Williams 2017-07-12 485 struct dax_device *dax_dev;
9567da0b408a25 Dan Williams 2017-07-12 486 struct dev_dax *dev_dax;
9567da0b408a25 Dan Williams 2017-07-12 487 struct inode *inode;
9567da0b408a25 Dan Williams 2017-07-12 488 struct device *dev;
79aac412b5c476 Dan Williams 2020-01-08 489 int rc;
9567da0b408a25 Dan Williams 2017-07-12 490
0997a0b7870fef Dan Williams 2020-01-06 491 if (data->id < 0)
9567da0b408a25 Dan Williams 2017-07-12 492 return ERR_PTR(-EINVAL);
9567da0b408a25 Dan Williams 2017-07-12 493
9567da0b408a25 Dan Williams 2017-07-12 494 dev_dax = kzalloc(sizeof(*dev_dax), GFP_KERNEL);
9567da0b408a25 Dan Williams 2017-07-12 495 if (!dev_dax)
9567da0b408a25 Dan Williams 2017-07-12 496 return ERR_PTR(-ENOMEM);
9567da0b408a25 Dan Williams 2017-07-12 497
79aac412b5c476 Dan Williams 2020-01-08 498 dev_dax->region = dax_region;
79aac412b5c476 Dan Williams 2020-01-08 499 dev = &dev_dax->dev;
79aac412b5c476 Dan Williams 2020-01-08 500 device_initialize(dev);
79aac412b5c476 Dan Williams 2020-01-08 501 dev_set_name(dev, "dax%d.%d", dax_region->id, data->id);
79aac412b5c476 Dan Williams 2020-01-08 502
79aac412b5c476 Dan Williams 2020-01-08 503 rc = alloc_dev_dax_range(dev_dax, data->size);
79aac412b5c476 Dan Williams 2020-01-08 504 if (rc)
79aac412b5c476 Dan Williams 2020-01-08 505 goto err_range;
79aac412b5c476 Dan Williams 2020-01-08 506
84cb8b1780cc7b Dan Williams 2020-01-06 507 if (data->pgmap) {
79aac412b5c476 Dan Williams 2020-01-08 508 dev_WARN_ONCE(parent, !is_static(dax_region),
79aac412b5c476 Dan Williams 2020-01-08 509 "custom dev_pagemap requires a static dax_region\n");
79aac412b5c476 Dan Williams 2020-01-08 510
84cb8b1780cc7b Dan Williams 2020-01-06 511 dev_dax->pgmap = kmemdup(data->pgmap,
84cb8b1780cc7b Dan Williams 2020-01-06 512 sizeof(struct dev_pagemap), GFP_KERNEL);
84cb8b1780cc7b Dan Williams 2020-01-06 513 if (!dev_dax->pgmap)
84cb8b1780cc7b Dan Williams 2020-01-06 514 goto err_pgmap;
Needs an "rc = -ENOMEM;"
84cb8b1780cc7b Dan Williams 2020-01-06 515 }
89ec9f2cfa36cc Dan Williams 2018-10-29 516
9567da0b408a25 Dan Williams 2017-07-12 517 /*
9567da0b408a25 Dan Williams 2017-07-12 518 * No 'host' or dax_operations since there is no access to this
9567da0b408a25 Dan Williams 2017-07-12 519 * device outside of mmap of the resulting character device.
9567da0b408a25 Dan Williams 2017-07-12 520 */
fefc1d97fa4b5e Pankaj Gupta 2019-07-05 521 dax_dev = alloc_dax(dev_dax, NULL, NULL, DAXDEV_F_SYNC);
4e4ced93794acb Vivek Goyal 2020-04-01 522 if (IS_ERR(dax_dev)) {
4e4ced93794acb Vivek Goyal 2020-04-01 523 rc = PTR_ERR(dax_dev);
84cb8b1780cc7b Dan Williams 2020-01-06 524 goto err_alloc_dax;
4e4ced93794acb Vivek Goyal 2020-04-01 525 }
9567da0b408a25 Dan Williams 2017-07-12 526
9567da0b408a25 Dan Williams 2017-07-12 527 /* a device_dax instance is dead while the driver is not attached */
9567da0b408a25 Dan Williams 2017-07-12 528 kill_dax(dax_dev);
9567da0b408a25 Dan Williams 2017-07-12 529
84cb8b1780cc7b Dan Williams 2020-01-06 530 /* from here on we're committed to teardown via dev_dax_release() */
9567da0b408a25 Dan Williams 2017-07-12 531 dev_dax->dax_dev = dax_dev;
8fc5c73554db0a Dan Williams 2018-11-09 532 dev_dax->target_node = dax_region->target_node;
9567da0b408a25 Dan Williams 2017-07-12 533 kref_get(&dax_region->kref);
9567da0b408a25 Dan Williams 2017-07-12 534
9567da0b408a25 Dan Williams 2017-07-12 535 inode = dax_inode(dax_dev);
9567da0b408a25 Dan Williams 2017-07-12 536 dev->devt = inode->i_rdev;
0997a0b7870fef Dan Williams 2020-01-06 537 if (data->subsys == DEV_DAX_BUS)
9567da0b408a25 Dan Williams 2017-07-12 538 dev->bus = &dax_bus_type;
730926c3b09989 Dan Williams 2017-07-16 539 else
730926c3b09989 Dan Williams 2017-07-16 540 dev->class = dax_class;
9567da0b408a25 Dan Williams 2017-07-12 541 dev->parent = parent;
770619a9510634 Dan Williams 2019-11-12 542 dev->type = &dev_dax_type;
9567da0b408a25 Dan Williams 2017-07-12 543
9567da0b408a25 Dan Williams 2017-07-12 544 rc = device_add(dev);
9567da0b408a25 Dan Williams 2017-07-12 545 if (rc) {
9567da0b408a25 Dan Williams 2017-07-12 546 kill_dev_dax(dev_dax);
9567da0b408a25 Dan Williams 2017-07-12 547 put_device(dev);
9567da0b408a25 Dan Williams 2017-07-12 548 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 549 }
9567da0b408a25 Dan Williams 2017-07-12 550
9567da0b408a25 Dan Williams 2017-07-12 551 rc = devm_add_action_or_reset(dax_region->dev, unregister_dev_dax, dev);
9567da0b408a25 Dan Williams 2017-07-12 552 if (rc)
9567da0b408a25 Dan Williams 2017-07-12 553 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 554
9567da0b408a25 Dan Williams 2017-07-12 555 return dev_dax;
79aac412b5c476 Dan Williams 2020-01-08 556
84cb8b1780cc7b Dan Williams 2020-01-06 557 err_alloc_dax:
84cb8b1780cc7b Dan Williams 2020-01-06 558 kfree(dev_dax->pgmap);
84cb8b1780cc7b Dan Williams 2020-01-06 559 err_pgmap:
79aac412b5c476 Dan Williams 2020-01-08 560 free_dev_dax_range(dev_dax);
79aac412b5c476 Dan Williams 2020-01-08 561 err_range:
9567da0b408a25 Dan Williams 2017-07-12 562 kfree(dev_dax);
9567da0b408a25 Dan Williams 2017-07-12 563
9567da0b408a25 Dan Williams 2017-07-12 @564 return ERR_PTR(rc);
9567da0b408a25 Dan Williams 2017-07-12 565 }
---
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: 36754 bytes --]
next reply other threads:[~2020-07-13 12:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 12:24 Dan Carpenter [this message]
2020-07-13 12:24 ` [nvdimm:libnvdimm-pending 15/22] drivers/dax/bus.c:564 devm_create_dev_dax() warn: passing zero to 'ERR_PTR' Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2020-07-10 17:39 kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200713122430.GP2549@kadam \
--to=dan.carpenter@oracle.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.