From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [linux-next:master 1249/1397] drivers/hwmon/axi-fan-control.c:418 axi_fan_control_probe() error: potentially dereferencing uninitialized 'res'.
Date: Tue, 11 Feb 2020 13:46:42 +0300 [thread overview]
Message-ID: <20200211104642.GA7838@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 6283 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: ac431e2d7b1be81bfe58163b9f81ba79bc987dc3
commit: 690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2 [1249/1397] hwmon: Support ADI Fan Control IP
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/hwmon/axi-fan-control.c:418 axi_fan_control_probe() error: potentially dereferencing uninitialized 'res'.
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2
vim +/res +418 drivers/hwmon/axi-fan-control.c
690dd9ce04f6a1 Nuno Sá 2019-10-09 386 static int axi_fan_control_probe(struct platform_device *pdev)
690dd9ce04f6a1 Nuno Sá 2019-10-09 387 {
690dd9ce04f6a1 Nuno Sá 2019-10-09 388 struct axi_fan_control_data *ctl;
690dd9ce04f6a1 Nuno Sá 2019-10-09 389 struct clk *clk;
690dd9ce04f6a1 Nuno Sá 2019-10-09 390 const struct of_device_id *id;
690dd9ce04f6a1 Nuno Sá 2019-10-09 391 const char *name = "axi_fan_control";
690dd9ce04f6a1 Nuno Sá 2019-10-09 392 struct resource *res;
690dd9ce04f6a1 Nuno Sá 2019-10-09 393 u32 version;
690dd9ce04f6a1 Nuno Sá 2019-10-09 394 int ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 395
690dd9ce04f6a1 Nuno Sá 2019-10-09 396 id = of_match_node(axi_fan_control_of_match, pdev->dev.of_node);
690dd9ce04f6a1 Nuno Sá 2019-10-09 397 if (!id)
690dd9ce04f6a1 Nuno Sá 2019-10-09 398 return -EINVAL;
690dd9ce04f6a1 Nuno Sá 2019-10-09 399
690dd9ce04f6a1 Nuno Sá 2019-10-09 400 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 401 if (!ctl)
690dd9ce04f6a1 Nuno Sá 2019-10-09 402 return -ENOMEM;
690dd9ce04f6a1 Nuno Sá 2019-10-09 403
690dd9ce04f6a1 Nuno Sá 2019-10-09 404 ctl->base = devm_platform_ioremap_resource(pdev, 0);
690dd9ce04f6a1 Nuno Sá 2019-10-09 405 if (IS_ERR(ctl->base))
690dd9ce04f6a1 Nuno Sá 2019-10-09 406 return PTR_ERR(ctl->base);
690dd9ce04f6a1 Nuno Sá 2019-10-09 407
690dd9ce04f6a1 Nuno Sá 2019-10-09 408 clk = devm_clk_get(&pdev->dev, NULL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 409 if (IS_ERR(clk)) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 410 dev_err(&pdev->dev, "clk_get failed with %ld\n", PTR_ERR(clk));
690dd9ce04f6a1 Nuno Sá 2019-10-09 411 return PTR_ERR(clk);
690dd9ce04f6a1 Nuno Sá 2019-10-09 412 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 413
690dd9ce04f6a1 Nuno Sá 2019-10-09 414 ctl->clk_rate = clk_get_rate(clk);
690dd9ce04f6a1 Nuno Sá 2019-10-09 415 if (!ctl->clk_rate)
690dd9ce04f6a1 Nuno Sá 2019-10-09 416 return -EINVAL;
690dd9ce04f6a1 Nuno Sá 2019-10-09 417
690dd9ce04f6a1 Nuno Sá 2019-10-09 @418 dev_dbg(&pdev->dev, "Re-mapped from 0x%08llX to %p\n",
690dd9ce04f6a1 Nuno Sá 2019-10-09 419 (unsigned long long)res->start, ctl->base);
^^^^^^^^^^
"res" is never set or used anywhere.
690dd9ce04f6a1 Nuno Sá 2019-10-09 420
690dd9ce04f6a1 Nuno Sá 2019-10-09 421 version = axi_ioread(ADI_AXI_REG_VERSION, ctl);
690dd9ce04f6a1 Nuno Sá 2019-10-09 422 if (ADI_AXI_PCORE_VER_MAJOR(version) !=
690dd9ce04f6a1 Nuno Sá 2019-10-09 423 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data))) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 424 dev_err(&pdev->dev, "Major version mismatch. Expected %d.%.2d.%c, Reported %d.%.2d.%c\n",
690dd9ce04f6a1 Nuno Sá 2019-10-09 425 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 426 ADI_AXI_PCORE_VER_MINOR((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 427 ADI_AXI_PCORE_VER_PATCH((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 428 ADI_AXI_PCORE_VER_MAJOR(version),
690dd9ce04f6a1 Nuno Sá 2019-10-09 429 ADI_AXI_PCORE_VER_MINOR(version),
690dd9ce04f6a1 Nuno Sá 2019-10-09 430 ADI_AXI_PCORE_VER_PATCH(version));
690dd9ce04f6a1 Nuno Sá 2019-10-09 431 return -ENODEV;
690dd9ce04f6a1 Nuno Sá 2019-10-09 432 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 433
690dd9ce04f6a1 Nuno Sá 2019-10-09 434 ctl->irq = platform_get_irq(pdev, 0);
690dd9ce04f6a1 Nuno Sá 2019-10-09 435 if (ctl->irq < 0)
690dd9ce04f6a1 Nuno Sá 2019-10-09 436 return ctl->irq;
690dd9ce04f6a1 Nuno Sá 2019-10-09 437
690dd9ce04f6a1 Nuno Sá 2019-10-09 438 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL,
690dd9ce04f6a1 Nuno Sá 2019-10-09 439 axi_fan_control_irq_handler,
690dd9ce04f6a1 Nuno Sá 2019-10-09 440 IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
690dd9ce04f6a1 Nuno Sá 2019-10-09 441 pdev->driver_override, ctl);
690dd9ce04f6a1 Nuno Sá 2019-10-09 442 if (ret) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 443 dev_err(&pdev->dev, "failed to request an irq, %d", ret);
690dd9ce04f6a1 Nuno Sá 2019-10-09 444 return ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 445 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 446
690dd9ce04f6a1 Nuno Sá 2019-10-09 447 ret = axi_fan_control_init(ctl, pdev->dev.of_node);
690dd9ce04f6a1 Nuno Sá 2019-10-09 448 if (ret) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 449 dev_err(&pdev->dev, "Failed to initialize device\n");
690dd9ce04f6a1 Nuno Sá 2019-10-09 450 return ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 451 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 452
690dd9ce04f6a1 Nuno Sá 2019-10-09 453 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev,
690dd9ce04f6a1 Nuno Sá 2019-10-09 454 name,
690dd9ce04f6a1 Nuno Sá 2019-10-09 455 ctl,
690dd9ce04f6a1 Nuno Sá 2019-10-09 456 &axi_chip_info,
690dd9ce04f6a1 Nuno Sá 2019-10-09 457 NULL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 458
690dd9ce04f6a1 Nuno Sá 2019-10-09 459 return PTR_ERR_OR_ZERO(ctl->hdev);
690dd9ce04f6a1 Nuno Sá 2019-10-09 460 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [linux-next:master 1249/1397] drivers/hwmon/axi-fan-control.c:418 axi_fan_control_probe() error: potentially dereferencing uninitialized 'res'.
Date: Tue, 11 Feb 2020 13:46:42 +0300 [thread overview]
Message-ID: <20200211104642.GA7838@kadam> (raw)
[-- Attachment #1: Type: text/plain, Size: 6283 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: ac431e2d7b1be81bfe58163b9f81ba79bc987dc3
commit: 690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2 [1249/1397] hwmon: Support ADI Fan Control IP
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/hwmon/axi-fan-control.c:418 axi_fan_control_probe() error: potentially dereferencing uninitialized 'res'.
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git remote update linux-next
git checkout 690dd9ce04f6a1b319bcb211ee0b3e125a4fa4f2
vim +/res +418 drivers/hwmon/axi-fan-control.c
690dd9ce04f6a1 Nuno Sá 2019-10-09 386 static int axi_fan_control_probe(struct platform_device *pdev)
690dd9ce04f6a1 Nuno Sá 2019-10-09 387 {
690dd9ce04f6a1 Nuno Sá 2019-10-09 388 struct axi_fan_control_data *ctl;
690dd9ce04f6a1 Nuno Sá 2019-10-09 389 struct clk *clk;
690dd9ce04f6a1 Nuno Sá 2019-10-09 390 const struct of_device_id *id;
690dd9ce04f6a1 Nuno Sá 2019-10-09 391 const char *name = "axi_fan_control";
690dd9ce04f6a1 Nuno Sá 2019-10-09 392 struct resource *res;
690dd9ce04f6a1 Nuno Sá 2019-10-09 393 u32 version;
690dd9ce04f6a1 Nuno Sá 2019-10-09 394 int ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 395
690dd9ce04f6a1 Nuno Sá 2019-10-09 396 id = of_match_node(axi_fan_control_of_match, pdev->dev.of_node);
690dd9ce04f6a1 Nuno Sá 2019-10-09 397 if (!id)
690dd9ce04f6a1 Nuno Sá 2019-10-09 398 return -EINVAL;
690dd9ce04f6a1 Nuno Sá 2019-10-09 399
690dd9ce04f6a1 Nuno Sá 2019-10-09 400 ctl = devm_kzalloc(&pdev->dev, sizeof(*ctl), GFP_KERNEL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 401 if (!ctl)
690dd9ce04f6a1 Nuno Sá 2019-10-09 402 return -ENOMEM;
690dd9ce04f6a1 Nuno Sá 2019-10-09 403
690dd9ce04f6a1 Nuno Sá 2019-10-09 404 ctl->base = devm_platform_ioremap_resource(pdev, 0);
690dd9ce04f6a1 Nuno Sá 2019-10-09 405 if (IS_ERR(ctl->base))
690dd9ce04f6a1 Nuno Sá 2019-10-09 406 return PTR_ERR(ctl->base);
690dd9ce04f6a1 Nuno Sá 2019-10-09 407
690dd9ce04f6a1 Nuno Sá 2019-10-09 408 clk = devm_clk_get(&pdev->dev, NULL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 409 if (IS_ERR(clk)) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 410 dev_err(&pdev->dev, "clk_get failed with %ld\n", PTR_ERR(clk));
690dd9ce04f6a1 Nuno Sá 2019-10-09 411 return PTR_ERR(clk);
690dd9ce04f6a1 Nuno Sá 2019-10-09 412 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 413
690dd9ce04f6a1 Nuno Sá 2019-10-09 414 ctl->clk_rate = clk_get_rate(clk);
690dd9ce04f6a1 Nuno Sá 2019-10-09 415 if (!ctl->clk_rate)
690dd9ce04f6a1 Nuno Sá 2019-10-09 416 return -EINVAL;
690dd9ce04f6a1 Nuno Sá 2019-10-09 417
690dd9ce04f6a1 Nuno Sá 2019-10-09 @418 dev_dbg(&pdev->dev, "Re-mapped from 0x%08llX to %p\n",
690dd9ce04f6a1 Nuno Sá 2019-10-09 419 (unsigned long long)res->start, ctl->base);
^^^^^^^^^^
"res" is never set or used anywhere.
690dd9ce04f6a1 Nuno Sá 2019-10-09 420
690dd9ce04f6a1 Nuno Sá 2019-10-09 421 version = axi_ioread(ADI_AXI_REG_VERSION, ctl);
690dd9ce04f6a1 Nuno Sá 2019-10-09 422 if (ADI_AXI_PCORE_VER_MAJOR(version) !=
690dd9ce04f6a1 Nuno Sá 2019-10-09 423 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data))) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 424 dev_err(&pdev->dev, "Major version mismatch. Expected %d.%.2d.%c, Reported %d.%.2d.%c\n",
690dd9ce04f6a1 Nuno Sá 2019-10-09 425 ADI_AXI_PCORE_VER_MAJOR((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 426 ADI_AXI_PCORE_VER_MINOR((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 427 ADI_AXI_PCORE_VER_PATCH((*(u32 *)id->data)),
690dd9ce04f6a1 Nuno Sá 2019-10-09 428 ADI_AXI_PCORE_VER_MAJOR(version),
690dd9ce04f6a1 Nuno Sá 2019-10-09 429 ADI_AXI_PCORE_VER_MINOR(version),
690dd9ce04f6a1 Nuno Sá 2019-10-09 430 ADI_AXI_PCORE_VER_PATCH(version));
690dd9ce04f6a1 Nuno Sá 2019-10-09 431 return -ENODEV;
690dd9ce04f6a1 Nuno Sá 2019-10-09 432 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 433
690dd9ce04f6a1 Nuno Sá 2019-10-09 434 ctl->irq = platform_get_irq(pdev, 0);
690dd9ce04f6a1 Nuno Sá 2019-10-09 435 if (ctl->irq < 0)
690dd9ce04f6a1 Nuno Sá 2019-10-09 436 return ctl->irq;
690dd9ce04f6a1 Nuno Sá 2019-10-09 437
690dd9ce04f6a1 Nuno Sá 2019-10-09 438 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL,
690dd9ce04f6a1 Nuno Sá 2019-10-09 439 axi_fan_control_irq_handler,
690dd9ce04f6a1 Nuno Sá 2019-10-09 440 IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
690dd9ce04f6a1 Nuno Sá 2019-10-09 441 pdev->driver_override, ctl);
690dd9ce04f6a1 Nuno Sá 2019-10-09 442 if (ret) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 443 dev_err(&pdev->dev, "failed to request an irq, %d", ret);
690dd9ce04f6a1 Nuno Sá 2019-10-09 444 return ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 445 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 446
690dd9ce04f6a1 Nuno Sá 2019-10-09 447 ret = axi_fan_control_init(ctl, pdev->dev.of_node);
690dd9ce04f6a1 Nuno Sá 2019-10-09 448 if (ret) {
690dd9ce04f6a1 Nuno Sá 2019-10-09 449 dev_err(&pdev->dev, "Failed to initialize device\n");
690dd9ce04f6a1 Nuno Sá 2019-10-09 450 return ret;
690dd9ce04f6a1 Nuno Sá 2019-10-09 451 }
690dd9ce04f6a1 Nuno Sá 2019-10-09 452
690dd9ce04f6a1 Nuno Sá 2019-10-09 453 ctl->hdev = devm_hwmon_device_register_with_info(&pdev->dev,
690dd9ce04f6a1 Nuno Sá 2019-10-09 454 name,
690dd9ce04f6a1 Nuno Sá 2019-10-09 455 ctl,
690dd9ce04f6a1 Nuno Sá 2019-10-09 456 &axi_chip_info,
690dd9ce04f6a1 Nuno Sá 2019-10-09 457 NULL);
690dd9ce04f6a1 Nuno Sá 2019-10-09 458
690dd9ce04f6a1 Nuno Sá 2019-10-09 459 return PTR_ERR_OR_ZERO(ctl->hdev);
690dd9ce04f6a1 Nuno Sá 2019-10-09 460 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next reply other threads:[~2020-02-11 10:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 10:46 Dan Carpenter [this message]
2020-02-11 10:46 ` [linux-next:master 1249/1397] drivers/hwmon/axi-fan-control.c:418 axi_fan_control_probe() error: potentially dereferencing uninitialized 'res' Dan Carpenter
2020-02-11 13:28 ` Guenter Roeck
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=20200211104642.GA7838@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.