* [cip:linux-5.10.y-cip-rebase 606/1105] drivers/usb/host/xhci-plat.c:382 xhci_generic_plat_probe() error: we previously assumed 'sysdev' could be null (see line 372)
@ 2024-10-14 23:01 kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2024-10-14 23:01 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip.git linux-5.10.y-cip-rebase
head: 3cdd0cc9c0e53917e2c4e56b1e7256ae8923845e
commit: 7ce55f4ea24048dd70fb4aa8f522c94d5f767f08 [606/1105] xhci: split out rcar/rz support from xhci-plat.c
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: x86_64-randconfig-161-20241014 (https://download.01.org/0day-ci/archive/20241015/202410150653.RDBoPiA3-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202410150653.RDBoPiA3-lkp@intel.com/
smatch warnings:
drivers/usb/host/xhci-plat.c:382 xhci_generic_plat_probe() error: we previously assumed 'sysdev' could be null (see line 372)
drivers/usb/host/xhci-plat.c:494 xhci_plat_resume() warn: 'xhci->clk' from clk_prepare_enable() not released on lines: 494.
drivers/usb/host/xhci-plat.c:494 xhci_plat_resume() warn: 'xhci->reg_clk' from clk_prepare_enable() not released on lines: 494.
vim +/sysdev +382 drivers/usb/host/xhci-plat.c
7ce55f4ea24048 Arnd Bergmann 2023-06-01 358
7ce55f4ea24048 Arnd Bergmann 2023-06-01 359 static int xhci_generic_plat_probe(struct platform_device *pdev)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 360 {
7ce55f4ea24048 Arnd Bergmann 2023-06-01 361 const struct xhci_plat_priv *priv_match;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 362 struct device *sysdev;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 363 int ret;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 364
7ce55f4ea24048 Arnd Bergmann 2023-06-01 365 /*
7ce55f4ea24048 Arnd Bergmann 2023-06-01 366 * sysdev must point to a device that is known to the system firmware
7ce55f4ea24048 Arnd Bergmann 2023-06-01 367 * or PCI hardware. We handle these three cases here:
7ce55f4ea24048 Arnd Bergmann 2023-06-01 368 * 1. xhci_plat comes from firmware
7ce55f4ea24048 Arnd Bergmann 2023-06-01 369 * 2. xhci_plat is child of a device from firmware (dwc3-plat)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 370 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 371 */
7ce55f4ea24048 Arnd Bergmann 2023-06-01 @372 for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) {
7ce55f4ea24048 Arnd Bergmann 2023-06-01 373 if (is_of_node(sysdev->fwnode) ||
7ce55f4ea24048 Arnd Bergmann 2023-06-01 374 is_acpi_device_node(sysdev->fwnode))
7ce55f4ea24048 Arnd Bergmann 2023-06-01 375 break;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 376 #ifdef CONFIG_PCI
7ce55f4ea24048 Arnd Bergmann 2023-06-01 377 else if (sysdev->bus == &pci_bus_type)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 378 break;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 379 #endif
7ce55f4ea24048 Arnd Bergmann 2023-06-01 380 }
7ce55f4ea24048 Arnd Bergmann 2023-06-01 381
7ce55f4ea24048 Arnd Bergmann 2023-06-01 @382 if (WARN_ON(!sysdev->dma_mask)) {
7ce55f4ea24048 Arnd Bergmann 2023-06-01 383 /* Platform did not initialize dma_mask */
7ce55f4ea24048 Arnd Bergmann 2023-06-01 384 ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
7ce55f4ea24048 Arnd Bergmann 2023-06-01 385 if (ret)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 386 return ret;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 387 }
7ce55f4ea24048 Arnd Bergmann 2023-06-01 388
7ce55f4ea24048 Arnd Bergmann 2023-06-01 389 if (pdev->dev.of_node)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 390 priv_match = of_device_get_match_data(&pdev->dev);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 391 else
7ce55f4ea24048 Arnd Bergmann 2023-06-01 392 priv_match = dev_get_platdata(&pdev->dev);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 393
7ce55f4ea24048 Arnd Bergmann 2023-06-01 394 return xhci_plat_probe(pdev, sysdev, priv_match);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 395 }
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 396
7ce55f4ea24048 Arnd Bergmann 2023-06-01 397 int xhci_plat_remove(struct platform_device *dev)
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 398 {
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 399 struct usb_hcd *hcd = platform_get_drvdata(dev);
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 400 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
4718c177405112 Gregory CLEMENT 2014-05-15 401 struct clk *clk = xhci->clk;
3ae2da7b28b393 Gregory CLEMENT 2018-04-20 402 struct clk *reg_clk = xhci->reg_clk;
f068090426ea8d Mathias Nyman 2018-11-09 403 struct usb_hcd *shared_hcd = xhci->shared_hcd;
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 404
1449cb2c2253d3 Li Jun 2020-05-14 405 pm_runtime_get_sync(&dev->dev);
dcc7620cad5ad1 Guenter Roeck 2017-03-09 406 xhci->xhc_state |= XHCI_STATE_REMOVING;
dcc7620cad5ad1 Guenter Roeck 2017-03-09 407
f068090426ea8d Mathias Nyman 2018-11-09 408 usb_remove_hcd(shared_hcd);
f068090426ea8d Mathias Nyman 2018-11-09 409 xhci->shared_hcd = NULL;
7b8ef22ea547b8 Maxime Ripard 2015-03-17 410 usb_phy_shutdown(hcd->usb_phy);
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 411
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 412 usb_remove_hcd(hcd);
f068090426ea8d Mathias Nyman 2018-11-09 413 usb_put_hcd(shared_hcd);
4ac53087d6d48e Roger Quadros 2015-05-29 414
4718c177405112 Gregory CLEMENT 2014-05-15 415 clk_disable_unprepare(clk);
3ae2da7b28b393 Gregory CLEMENT 2018-04-20 416 clk_disable_unprepare(reg_clk);
8b67c4750f869a Biju Das 2023-06-01 417 reset_control_assert(xhci->reset);
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 418 usb_put_hcd(hcd);
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 419
b0c69b4bace370 Baolin Wang 2017-04-19 420 pm_runtime_disable(&dev->dev);
1449cb2c2253d3 Li Jun 2020-05-14 421 pm_runtime_put_noidle(&dev->dev);
1449cb2c2253d3 Li Jun 2020-05-14 422 pm_runtime_set_suspended(&dev->dev);
b0c69b4bace370 Baolin Wang 2017-04-19 423
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 424 return 0;
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 425 }
7ce55f4ea24048 Arnd Bergmann 2023-06-01 426 EXPORT_SYMBOL_GPL(xhci_plat_remove);
3429e91a661e1f Sebastian Andrzej Siewior 2012-03-13 427
d852ed98f62e0d Arnd Bergmann 2017-04-21 428 static int __maybe_unused xhci_plat_suspend(struct device *dev)
57d04eb131ec9d Vikas Sajjan 2013-02-11 429 {
57d04eb131ec9d Vikas Sajjan 2013-02-11 430 struct usb_hcd *hcd = dev_get_drvdata(dev);
57d04eb131ec9d Vikas Sajjan 2013-02-11 431 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
5e0e54ff892487 Peter Chen 2020-09-18 432 int ret;
57d04eb131ec9d Vikas Sajjan 2013-02-11 433
20c51a4c52208f Frank Li 2022-01-10 434 if (pm_runtime_suspended(dev))
20c51a4c52208f Frank Li 2022-01-10 435 pm_runtime_resume(dev);
20c51a4c52208f Frank Li 2022-01-10 436
5e0e54ff892487 Peter Chen 2020-09-18 437 ret = xhci_priv_suspend_quirk(hcd);
5e0e54ff892487 Peter Chen 2020-09-18 438 if (ret)
5e0e54ff892487 Peter Chen 2020-09-18 439 return ret;
a1377e5397ab32 Lu Baolu 2014-11-18 440 /*
a1377e5397ab32 Lu Baolu 2014-11-18 441 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
9cdda28d3278e4 Peter Chen 2020-09-18 442 * to do wakeup during suspend.
a1377e5397ab32 Lu Baolu 2014-11-18 443 */
c13d0d2f5a4806 Justin Chen 2022-08-10 444 ret = xhci_suspend(xhci, device_may_wakeup(dev));
c13d0d2f5a4806 Justin Chen 2022-08-10 445 if (ret)
c13d0d2f5a4806 Justin Chen 2022-08-10 446 return ret;
c13d0d2f5a4806 Justin Chen 2022-08-10 447
c13d0d2f5a4806 Justin Chen 2022-08-10 448 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
c13d0d2f5a4806 Justin Chen 2022-08-10 449 clk_disable_unprepare(xhci->clk);
c13d0d2f5a4806 Justin Chen 2022-08-10 450 clk_disable_unprepare(xhci->reg_clk);
c13d0d2f5a4806 Justin Chen 2022-08-10 451 }
c13d0d2f5a4806 Justin Chen 2022-08-10 452
c13d0d2f5a4806 Justin Chen 2022-08-10 453 return 0;
57d04eb131ec9d Vikas Sajjan 2013-02-11 454 }
57d04eb131ec9d Vikas Sajjan 2013-02-11 455
d852ed98f62e0d Arnd Bergmann 2017-04-21 456 static int __maybe_unused xhci_plat_resume(struct device *dev)
57d04eb131ec9d Vikas Sajjan 2013-02-11 457 {
57d04eb131ec9d Vikas Sajjan 2013-02-11 458 struct usb_hcd *hcd = dev_get_drvdata(dev);
57d04eb131ec9d Vikas Sajjan 2013-02-11 459 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
98c0a3ffa30c4b Yoshihiro Shimoda 2017-04-19 460 int ret;
57d04eb131ec9d Vikas Sajjan 2013-02-11 461
c13d0d2f5a4806 Justin Chen 2022-08-10 462 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
188425eb2da2a0 Sergey Shtylyov 2023-10-19 463 ret = clk_prepare_enable(xhci->clk);
188425eb2da2a0 Sergey Shtylyov 2023-10-19 464 if (ret)
188425eb2da2a0 Sergey Shtylyov 2023-10-19 465 return ret;
188425eb2da2a0 Sergey Shtylyov 2023-10-19 466
188425eb2da2a0 Sergey Shtylyov 2023-10-19 467 ret = clk_prepare_enable(xhci->reg_clk);
188425eb2da2a0 Sergey Shtylyov 2023-10-19 468 if (ret) {
188425eb2da2a0 Sergey Shtylyov 2023-10-19 469 clk_disable_unprepare(xhci->clk);
188425eb2da2a0 Sergey Shtylyov 2023-10-19 470 return ret;
188425eb2da2a0 Sergey Shtylyov 2023-10-19 471 }
c13d0d2f5a4806 Justin Chen 2022-08-10 472 }
c13d0d2f5a4806 Justin Chen 2022-08-10 473
98c0a3ffa30c4b Yoshihiro Shimoda 2017-04-19 474 ret = xhci_priv_resume_quirk(hcd);
98c0a3ffa30c4b Yoshihiro Shimoda 2017-04-19 475 if (ret)
188425eb2da2a0 Sergey Shtylyov 2023-10-19 476 goto disable_clks;
98c0a3ffa30c4b Yoshihiro Shimoda 2017-04-19 477
79112cc3c29f4a Qais Yousef 2020-05-18 478 ret = xhci_resume(xhci, 0);
79112cc3c29f4a Qais Yousef 2020-05-18 479 if (ret)
188425eb2da2a0 Sergey Shtylyov 2023-10-19 480 goto disable_clks;
79112cc3c29f4a Qais Yousef 2020-05-18 481
79112cc3c29f4a Qais Yousef 2020-05-18 482 pm_runtime_disable(dev);
79112cc3c29f4a Qais Yousef 2020-05-18 483 pm_runtime_set_active(dev);
79112cc3c29f4a Qais Yousef 2020-05-18 484 pm_runtime_enable(dev);
79112cc3c29f4a Qais Yousef 2020-05-18 485
79112cc3c29f4a Qais Yousef 2020-05-18 486 return 0;
188425eb2da2a0 Sergey Shtylyov 2023-10-19 487
188425eb2da2a0 Sergey Shtylyov 2023-10-19 488 disable_clks:
188425eb2da2a0 Sergey Shtylyov 2023-10-19 489 if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) {
188425eb2da2a0 Sergey Shtylyov 2023-10-19 490 clk_disable_unprepare(xhci->clk);
188425eb2da2a0 Sergey Shtylyov 2023-10-19 491 clk_disable_unprepare(xhci->reg_clk);
188425eb2da2a0 Sergey Shtylyov 2023-10-19 492 }
188425eb2da2a0 Sergey Shtylyov 2023-10-19 493
188425eb2da2a0 Sergey Shtylyov 2023-10-19 @494 return ret;
57d04eb131ec9d Vikas Sajjan 2013-02-11 495 }
b0c69b4bace370 Baolin Wang 2017-04-19 496
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread* [cip:linux-5.10.y-cip-rebase 606/1105] drivers/usb/host/xhci-plat.c:382 xhci_generic_plat_probe() error: we previously assumed 'sysdev' could be null (see line 372)
@ 2024-10-15 9:35 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2024-10-15 9:35 UTC (permalink / raw)
To: oe-kbuild, Nobuhiro Iwamatsu; +Cc: lkp, oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cip/linux-cip.git linux-5.10.y-cip-rebase
head: 3cdd0cc9c0e53917e2c4e56b1e7256ae8923845e
commit: 7ce55f4ea24048dd70fb4aa8f522c94d5f767f08 [606/1105] xhci: split out rcar/rz support from xhci-plat.c
config: x86_64-randconfig-161-20241014 (https://download.01.org/0day-ci/archive/20241015/202410150653.RDBoPiA3-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202410150653.RDBoPiA3-lkp@intel.com/
smatch warnings:
drivers/usb/host/xhci-plat.c:382 xhci_generic_plat_probe() error: we previously assumed 'sysdev' could be null (see line 372)
vim +/sysdev +382 drivers/usb/host/xhci-plat.c
7ce55f4ea24048 Arnd Bergmann 2023-06-01 359 static int xhci_generic_plat_probe(struct platform_device *pdev)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 360 {
7ce55f4ea24048 Arnd Bergmann 2023-06-01 361 const struct xhci_plat_priv *priv_match;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 362 struct device *sysdev;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 363 int ret;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 364
7ce55f4ea24048 Arnd Bergmann 2023-06-01 365 /*
7ce55f4ea24048 Arnd Bergmann 2023-06-01 366 * sysdev must point to a device that is known to the system firmware
7ce55f4ea24048 Arnd Bergmann 2023-06-01 367 * or PCI hardware. We handle these three cases here:
7ce55f4ea24048 Arnd Bergmann 2023-06-01 368 * 1. xhci_plat comes from firmware
7ce55f4ea24048 Arnd Bergmann 2023-06-01 369 * 2. xhci_plat is child of a device from firmware (dwc3-plat)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 370 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 371 */
7ce55f4ea24048 Arnd Bergmann 2023-06-01 @372 for (sysdev = &pdev->dev; sysdev; sysdev = sysdev->parent) {
^^^^^^
This loop exits with a NULL sysdev pointer
7ce55f4ea24048 Arnd Bergmann 2023-06-01 373 if (is_of_node(sysdev->fwnode) ||
7ce55f4ea24048 Arnd Bergmann 2023-06-01 374 is_acpi_device_node(sysdev->fwnode))
7ce55f4ea24048 Arnd Bergmann 2023-06-01 375 break;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 376 #ifdef CONFIG_PCI
7ce55f4ea24048 Arnd Bergmann 2023-06-01 377 else if (sysdev->bus == &pci_bus_type)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 378 break;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 379 #endif
7ce55f4ea24048 Arnd Bergmann 2023-06-01 380 }
7ce55f4ea24048 Arnd Bergmann 2023-06-01 381
7ce55f4ea24048 Arnd Bergmann 2023-06-01 @382 if (WARN_ON(!sysdev->dma_mask)) {
^^^^^^^^^^^^^^^^
Unchecked dereference
7ce55f4ea24048 Arnd Bergmann 2023-06-01 383 /* Platform did not initialize dma_mask */
7ce55f4ea24048 Arnd Bergmann 2023-06-01 384 ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
7ce55f4ea24048 Arnd Bergmann 2023-06-01 385 if (ret)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 386 return ret;
7ce55f4ea24048 Arnd Bergmann 2023-06-01 387 }
7ce55f4ea24048 Arnd Bergmann 2023-06-01 388
7ce55f4ea24048 Arnd Bergmann 2023-06-01 389 if (pdev->dev.of_node)
7ce55f4ea24048 Arnd Bergmann 2023-06-01 390 priv_match = of_device_get_match_data(&pdev->dev);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 391 else
7ce55f4ea24048 Arnd Bergmann 2023-06-01 392 priv_match = dev_get_platdata(&pdev->dev);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 393
7ce55f4ea24048 Arnd Bergmann 2023-06-01 394 return xhci_plat_probe(pdev, sysdev, priv_match);
7ce55f4ea24048 Arnd Bergmann 2023-06-01 395 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-15 9:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 23:01 [cip:linux-5.10.y-cip-rebase 606/1105] drivers/usb/host/xhci-plat.c:382 xhci_generic_plat_probe() error: we previously assumed 'sysdev' could be null (see line 372) kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2024-10-15 9:35 Dan Carpenter
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.