Re: [PATCH v2 2/2] remoteproc: enhance rproc_put() for clusters

From: Dan Carpenter
Date: Wed Mar 22 2023 - 07:52:57 EST


Hi Tanmay,

url: https://github.com/intel-lab-lkp/linux/commits/Tanmay-Shah/remoteproc-Make-rproc_get_by_phandle-work-for-clusters/20230322-121102
base: e19967994d342a5986d950a1bfddf19d7e1191b7
patch link: https://lore.kernel.org/r/20230322040933.924813-3-tanmay.shah%40amd.com
patch subject: [PATCH v2 2/2] remoteproc: enhance rproc_put() for clusters
config: powerpc-randconfig-m041-20230322 (https://download.01.org/0day-ci/archive/20230322/202303221916.LgKkr8Gk-lkp@xxxxxxxxx/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Link: https://lore.kernel.org/r/202303221916.LgKkr8Gk-lkp@xxxxxxxxx/

smatch warnings:
drivers/remoteproc/remoteproc_core.c:2565 rproc_put() warn: variable dereferenced before check 'rproc->dev.parent' (see line 2562)
drivers/remoteproc/remoteproc_core.c:2566 rproc_put() warn: variable dereferenced before check 'rproc->dev.parent->driver' (see line 2562)

vim +2565 drivers/remoteproc/remoteproc_core.c

160e7c840fe858 Ohad Ben-Cohen 2012-07-04 2560 void rproc_put(struct rproc *rproc)
400e64df6b237e Ohad Ben-Cohen 2011-10-20 2561 {
fbb6aacb078285 Bjorn Andersson 2016-10-02 @2562 module_put(rproc->dev.parent->driver->owner);
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unchecked dereferences.

573d22d13a6970 Tanmay Shah 2023-03-21 2563 struct platform_device *cluster_pdev;
573d22d13a6970 Tanmay Shah 2023-03-21 2564
573d22d13a6970 Tanmay Shah 2023-03-21 @2565 if (rproc->dev.parent) {
^^^^^^^^^^^^^^^^^
Checked too late.

573d22d13a6970 Tanmay Shah 2023-03-21 @2566 if (rproc->dev.parent->driver) {
^^^^^^^^^^^^^^^^^^^^^^^^^

573d22d13a6970 Tanmay Shah 2023-03-21 2567 module_put(rproc->dev.parent->driver->owner);
573d22d13a6970 Tanmay Shah 2023-03-21 2568 } else {
573d22d13a6970 Tanmay Shah 2023-03-21 2569 cluster_pdev = of_find_device_by_node(rproc->dev.parent->of_node->parent);
573d22d13a6970 Tanmay Shah 2023-03-21 2570 if (cluster_pdev) {
573d22d13a6970 Tanmay Shah 2023-03-21 2571 module_put(cluster_pdev->dev.driver->owner);
573d22d13a6970 Tanmay Shah 2023-03-21 2572 put_device(&cluster_pdev->dev);
573d22d13a6970 Tanmay Shah 2023-03-21 2573 }
573d22d13a6970 Tanmay Shah 2023-03-21 2574 }
573d22d13a6970 Tanmay Shah 2023-03-21 2575 }
b5ab5e24e960b9 Ohad Ben-Cohen 2012-05-30 2576 put_device(&rproc->dev);
400e64df6b237e Ohad Ben-Cohen 2011-10-20 2577 }

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests