From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [intel-linux-intel-lts:5.4/yocto 2/3] drivers/tcc/tcc_buffer.c:629 tcc_buffer_init() warn: returning -1 instead of -ENOMEM is sloppy
Date: Fri, 11 Dec 2020 10:45:44 +0300 [thread overview]
Message-ID: <20201211074544.GO2767@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 5476 bytes --]
tree: https://github.com/intel/linux-intel-lts.git 5.4/yocto
head: bda68cfc97bb728fbb144928c2269de95e433a76
commit: a83e0909a8eb378a3a62a3c14d2a555784216cec [2/3] tcc: this is kernel driver to interface to TCC PTCM pesudo SRAM
config: i386-randconfig-m021-20201211 (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>
New smatch warnings:
drivers/tcc/tcc_buffer.c:629 tcc_buffer_init() warn: returning -1 instead of -ENOMEM is sloppy
Old smatch warnings:
drivers/tcc/tcc_buffer.c:289 tcc_parse_ptct() warn: returning -1 instead of -ENOMEM is sloppy
drivers/tcc/tcc_buffer.c:312 tcc_parse_ptct() warn: returning -1 instead of -ENOMEM is sloppy
vim +629 drivers/tcc/tcc_buffer.c
a83e0909a8eb37 Qiang Rao 2020-05-26 614 static int __init tcc_buffer_init(void)
a83e0909a8eb37 Qiang Rao 2020-05-26 615 {
a83e0909a8eb37 Qiang Rao 2020-05-26 616 int ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 617 struct device *dev_ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 618 u32 new_minor = UNDEFINED_DEVNODE;
a83e0909a8eb37 Qiang Rao 2020-05-26 619 acpi_status status = AE_OK;
a83e0909a8eb37 Qiang Rao 2020-05-26 620
a83e0909a8eb37 Qiang Rao 2020-05-26 621 status = acpi_get_table(ACPI_SIG_PTCT, 0, &acpi_ptct_tbl);
a83e0909a8eb37 Qiang Rao 2020-05-26 622 if (ACPI_FAILURE(status) || !acpi_ptct_tbl) {
a83e0909a8eb37 Qiang Rao 2020-05-26 623 pr_err("Stop! ACPI doesn't provide PTCT.");
a83e0909a8eb37 Qiang Rao 2020-05-26 624 return -1;
a83e0909a8eb37 Qiang Rao 2020-05-26 625 }
a83e0909a8eb37 Qiang Rao 2020-05-26 626
a83e0909a8eb37 Qiang Rao 2020-05-26 627 p_tcc_config = kzalloc(sizeof(struct tcc_config), GFP_KERNEL);
a83e0909a8eb37 Qiang Rao 2020-05-26 628 if (!p_tcc_config)
a83e0909a8eb37 Qiang Rao 2020-05-26 @629 return -1;
^^^^^^^^^
return -ENOMEM;
a83e0909a8eb37 Qiang Rao 2020-05-26 630 INIT_LIST_HEAD(&p_tcc_config->psrams);
a83e0909a8eb37 Qiang Rao 2020-05-26 631
a83e0909a8eb37 Qiang Rao 2020-05-26 632 ret = tcc_parse_ptct();
a83e0909a8eb37 Qiang Rao 2020-05-26 633 if (ret != 0)
a83e0909a8eb37 Qiang Rao 2020-05-26 634 goto err_exit;
a83e0909a8eb37 Qiang Rao 2020-05-26 635
a83e0909a8eb37 Qiang Rao 2020-05-26 636 ret = register_chrdev(0, TCC_BUFFER_NAME, &tcc_buffer_fops);
a83e0909a8eb37 Qiang Rao 2020-05-26 637 if (ret < 0) {
a83e0909a8eb37 Qiang Rao 2020-05-26 638 pr_err("Couldn't regiter_chrdev, returen error=%d\n", ret);
a83e0909a8eb37 Qiang Rao 2020-05-26 639 goto err_exit;
a83e0909a8eb37 Qiang Rao 2020-05-26 640 }
a83e0909a8eb37 Qiang Rao 2020-05-26 641 tcc_buffer_device_major = ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 642
a83e0909a8eb37 Qiang Rao 2020-05-26 643 ret = tcc_buffer_minor_get(&new_minor);
a83e0909a8eb37 Qiang Rao 2020-05-26 644 if (ret < 0) {
a83e0909a8eb37 Qiang Rao 2020-05-26 645 pr_err("Unable to obtain a new minor number\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 646 goto err_class;
a83e0909a8eb37 Qiang Rao 2020-05-26 647 }
a83e0909a8eb37 Qiang Rao 2020-05-26 648
a83e0909a8eb37 Qiang Rao 2020-05-26 649 tcc_buffer_class = class_create(THIS_MODULE, TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 650 if (IS_ERR(tcc_buffer_class)) {
a83e0909a8eb37 Qiang Rao 2020-05-26 651 ret = PTR_ERR(tcc_buffer_class);
a83e0909a8eb37 Qiang Rao 2020-05-26 652 pr_err("Create class failed!\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 653 goto err_class;
a83e0909a8eb37 Qiang Rao 2020-05-26 654 }
a83e0909a8eb37 Qiang Rao 2020-05-26 655
a83e0909a8eb37 Qiang Rao 2020-05-26 656 dev_ret = device_create(tcc_buffer_class, NULL,
a83e0909a8eb37 Qiang Rao 2020-05-26 657 MKDEV(tcc_buffer_device_major, new_minor), NULL,
a83e0909a8eb37 Qiang Rao 2020-05-26 658 TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 659
a83e0909a8eb37 Qiang Rao 2020-05-26 660 if (IS_ERR(dev_ret)) {
a83e0909a8eb37 Qiang Rao 2020-05-26 661 ret = PTR_ERR(dev_ret);
a83e0909a8eb37 Qiang Rao 2020-05-26 662 pr_err("Failed to create character device\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 663 goto err_device;
a83e0909a8eb37 Qiang Rao 2020-05-26 664 }
a83e0909a8eb37 Qiang Rao 2020-05-26 665 tcc_init = 1;
a83e0909a8eb37 Qiang Rao 2020-05-26 666 p_tcc_config->minor = new_minor;
a83e0909a8eb37 Qiang Rao 2020-05-26 667
a83e0909a8eb37 Qiang Rao 2020-05-26 668 pr_err("TCC buffer init successfully\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 669 return 0;
a83e0909a8eb37 Qiang Rao 2020-05-26 670
a83e0909a8eb37 Qiang Rao 2020-05-26 671 err_device:
a83e0909a8eb37 Qiang Rao 2020-05-26 672 class_destroy(tcc_buffer_class);
a83e0909a8eb37 Qiang Rao 2020-05-26 673 err_class:
a83e0909a8eb37 Qiang Rao 2020-05-26 674 unregister_chrdev(tcc_buffer_device_major, TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 675 err_exit:
a83e0909a8eb37 Qiang Rao 2020-05-26 676 tcc_cleanup();
a83e0909a8eb37 Qiang Rao 2020-05-26 677 kfree(p_tcc_config);
a83e0909a8eb37 Qiang Rao 2020-05-26 678 return ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 679 }
---
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: 28100 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [intel-linux-intel-lts:5.4/yocto 2/3] drivers/tcc/tcc_buffer.c:629 tcc_buffer_init() warn: returning -1 instead of -ENOMEM is sloppy
Date: Fri, 11 Dec 2020 10:45:44 +0300 [thread overview]
Message-ID: <20201211074544.GO2767@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 5476 bytes --]
tree: https://github.com/intel/linux-intel-lts.git 5.4/yocto
head: bda68cfc97bb728fbb144928c2269de95e433a76
commit: a83e0909a8eb378a3a62a3c14d2a555784216cec [2/3] tcc: this is kernel driver to interface to TCC PTCM pesudo SRAM
config: i386-randconfig-m021-20201211 (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>
New smatch warnings:
drivers/tcc/tcc_buffer.c:629 tcc_buffer_init() warn: returning -1 instead of -ENOMEM is sloppy
Old smatch warnings:
drivers/tcc/tcc_buffer.c:289 tcc_parse_ptct() warn: returning -1 instead of -ENOMEM is sloppy
drivers/tcc/tcc_buffer.c:312 tcc_parse_ptct() warn: returning -1 instead of -ENOMEM is sloppy
vim +629 drivers/tcc/tcc_buffer.c
a83e0909a8eb37 Qiang Rao 2020-05-26 614 static int __init tcc_buffer_init(void)
a83e0909a8eb37 Qiang Rao 2020-05-26 615 {
a83e0909a8eb37 Qiang Rao 2020-05-26 616 int ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 617 struct device *dev_ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 618 u32 new_minor = UNDEFINED_DEVNODE;
a83e0909a8eb37 Qiang Rao 2020-05-26 619 acpi_status status = AE_OK;
a83e0909a8eb37 Qiang Rao 2020-05-26 620
a83e0909a8eb37 Qiang Rao 2020-05-26 621 status = acpi_get_table(ACPI_SIG_PTCT, 0, &acpi_ptct_tbl);
a83e0909a8eb37 Qiang Rao 2020-05-26 622 if (ACPI_FAILURE(status) || !acpi_ptct_tbl) {
a83e0909a8eb37 Qiang Rao 2020-05-26 623 pr_err("Stop! ACPI doesn't provide PTCT.");
a83e0909a8eb37 Qiang Rao 2020-05-26 624 return -1;
a83e0909a8eb37 Qiang Rao 2020-05-26 625 }
a83e0909a8eb37 Qiang Rao 2020-05-26 626
a83e0909a8eb37 Qiang Rao 2020-05-26 627 p_tcc_config = kzalloc(sizeof(struct tcc_config), GFP_KERNEL);
a83e0909a8eb37 Qiang Rao 2020-05-26 628 if (!p_tcc_config)
a83e0909a8eb37 Qiang Rao 2020-05-26 @629 return -1;
^^^^^^^^^
return -ENOMEM;
a83e0909a8eb37 Qiang Rao 2020-05-26 630 INIT_LIST_HEAD(&p_tcc_config->psrams);
a83e0909a8eb37 Qiang Rao 2020-05-26 631
a83e0909a8eb37 Qiang Rao 2020-05-26 632 ret = tcc_parse_ptct();
a83e0909a8eb37 Qiang Rao 2020-05-26 633 if (ret != 0)
a83e0909a8eb37 Qiang Rao 2020-05-26 634 goto err_exit;
a83e0909a8eb37 Qiang Rao 2020-05-26 635
a83e0909a8eb37 Qiang Rao 2020-05-26 636 ret = register_chrdev(0, TCC_BUFFER_NAME, &tcc_buffer_fops);
a83e0909a8eb37 Qiang Rao 2020-05-26 637 if (ret < 0) {
a83e0909a8eb37 Qiang Rao 2020-05-26 638 pr_err("Couldn't regiter_chrdev, returen error=%d\n", ret);
a83e0909a8eb37 Qiang Rao 2020-05-26 639 goto err_exit;
a83e0909a8eb37 Qiang Rao 2020-05-26 640 }
a83e0909a8eb37 Qiang Rao 2020-05-26 641 tcc_buffer_device_major = ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 642
a83e0909a8eb37 Qiang Rao 2020-05-26 643 ret = tcc_buffer_minor_get(&new_minor);
a83e0909a8eb37 Qiang Rao 2020-05-26 644 if (ret < 0) {
a83e0909a8eb37 Qiang Rao 2020-05-26 645 pr_err("Unable to obtain a new minor number\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 646 goto err_class;
a83e0909a8eb37 Qiang Rao 2020-05-26 647 }
a83e0909a8eb37 Qiang Rao 2020-05-26 648
a83e0909a8eb37 Qiang Rao 2020-05-26 649 tcc_buffer_class = class_create(THIS_MODULE, TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 650 if (IS_ERR(tcc_buffer_class)) {
a83e0909a8eb37 Qiang Rao 2020-05-26 651 ret = PTR_ERR(tcc_buffer_class);
a83e0909a8eb37 Qiang Rao 2020-05-26 652 pr_err("Create class failed!\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 653 goto err_class;
a83e0909a8eb37 Qiang Rao 2020-05-26 654 }
a83e0909a8eb37 Qiang Rao 2020-05-26 655
a83e0909a8eb37 Qiang Rao 2020-05-26 656 dev_ret = device_create(tcc_buffer_class, NULL,
a83e0909a8eb37 Qiang Rao 2020-05-26 657 MKDEV(tcc_buffer_device_major, new_minor), NULL,
a83e0909a8eb37 Qiang Rao 2020-05-26 658 TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 659
a83e0909a8eb37 Qiang Rao 2020-05-26 660 if (IS_ERR(dev_ret)) {
a83e0909a8eb37 Qiang Rao 2020-05-26 661 ret = PTR_ERR(dev_ret);
a83e0909a8eb37 Qiang Rao 2020-05-26 662 pr_err("Failed to create character device\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 663 goto err_device;
a83e0909a8eb37 Qiang Rao 2020-05-26 664 }
a83e0909a8eb37 Qiang Rao 2020-05-26 665 tcc_init = 1;
a83e0909a8eb37 Qiang Rao 2020-05-26 666 p_tcc_config->minor = new_minor;
a83e0909a8eb37 Qiang Rao 2020-05-26 667
a83e0909a8eb37 Qiang Rao 2020-05-26 668 pr_err("TCC buffer init successfully\n");
a83e0909a8eb37 Qiang Rao 2020-05-26 669 return 0;
a83e0909a8eb37 Qiang Rao 2020-05-26 670
a83e0909a8eb37 Qiang Rao 2020-05-26 671 err_device:
a83e0909a8eb37 Qiang Rao 2020-05-26 672 class_destroy(tcc_buffer_class);
a83e0909a8eb37 Qiang Rao 2020-05-26 673 err_class:
a83e0909a8eb37 Qiang Rao 2020-05-26 674 unregister_chrdev(tcc_buffer_device_major, TCC_BUFFER_NAME);
a83e0909a8eb37 Qiang Rao 2020-05-26 675 err_exit:
a83e0909a8eb37 Qiang Rao 2020-05-26 676 tcc_cleanup();
a83e0909a8eb37 Qiang Rao 2020-05-26 677 kfree(p_tcc_config);
a83e0909a8eb37 Qiang Rao 2020-05-26 678 return ret;
a83e0909a8eb37 Qiang Rao 2020-05-26 679 }
---
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: 28100 bytes --]
next reply other threads:[~2020-12-11 7:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 7:45 Dan Carpenter [this message]
2020-12-11 7:45 ` [intel-linux-intel-lts:5.4/yocto 2/3] drivers/tcc/tcc_buffer.c:629 tcc_buffer_init() warn: returning -1 instead of -ENOMEM is sloppy Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2020-12-11 0:56 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=20201211074544.GO2767@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.