linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v5 13/19] remoteproc: Properly deal with the resource table (fwd)
@ 2021-02-14 22:33 Julia Lawall
  0 siblings, 0 replies; only message in thread
From: Julia Lawall @ 2021-02-14 22:33 UTC (permalink / raw)
  To: Mathieu Poirier, ohad, bjorn.andersson, arnaud.pouliquen
  Cc: robh+dt, mcoquelin.stm32, alexandre.torgue, linux-remoteproc,
	devicetree, linux-kernel, linux-arm-kernel, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7944 bytes --]

There are identical kfrees on lines 2078 and 2080.

julia

---------- Forwarded message ----------
Date: Fri, 12 Feb 2021 10:45:50 +0800
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Cc: lkp@intel.com, Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH v5 13/19] remoteproc: Properly deal with the resource table

CC: kbuild-all@lists.01.org
In-Reply-To: <20210211234627.2669674-14-mathieu.poirier@linaro.org>
References: <20210211234627.2669674-14-mathieu.poirier@linaro.org>
TO: Mathieu Poirier <mathieu.poirier@linaro.org>
TO: ohad@wizery.com
TO: bjorn.andersson@linaro.org
TO: arnaud.pouliquen@st.com
CC: robh+dt@kernel.org
CC: mcoquelin.stm32@gmail.com
CC: alexandre.torgue@st.com
CC: linux-remoteproc@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-arm-kernel@lists.infradead.org

Hi Mathieu,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v5.11-rc7 next-20210211]
[cannot apply to remoteproc/for-next rpmsg/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mathieu-Poirier/remoteproc-Add-support-for-detaching-a-remote-processor/20210212-075607
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: openrisc-randconfig-c003-20210209 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


"coccinelle warnings: (new ones prefixed by >>)"
>> drivers/remoteproc/remoteproc_core.c:2080:7-26: ERROR: reference preceded by free on line 2078

vim +2080 drivers/remoteproc/remoteproc_core.c

400e64df6b237e Ohad Ben-Cohen  2011-10-20  2012
eab58da78fe46f Mathieu Poirier 2021-02-11  2013  /**
eab58da78fe46f Mathieu Poirier 2021-02-11  2014   * rproc_detach() - Detach the remote processor from the
eab58da78fe46f Mathieu Poirier 2021-02-11  2015   * remoteproc core
eab58da78fe46f Mathieu Poirier 2021-02-11  2016   *
eab58da78fe46f Mathieu Poirier 2021-02-11  2017   * @rproc: the remote processor
eab58da78fe46f Mathieu Poirier 2021-02-11  2018   *
eab58da78fe46f Mathieu Poirier 2021-02-11  2019   * Detach a remote processor (previously attached to with rproc_attach()).
eab58da78fe46f Mathieu Poirier 2021-02-11  2020   *
eab58da78fe46f Mathieu Poirier 2021-02-11  2021   * In case @rproc is still being used by an additional user(s), then
eab58da78fe46f Mathieu Poirier 2021-02-11  2022   * this function will just decrement the power refcount and exit,
eab58da78fe46f Mathieu Poirier 2021-02-11  2023   * without disconnecting the device.
eab58da78fe46f Mathieu Poirier 2021-02-11  2024   *
eab58da78fe46f Mathieu Poirier 2021-02-11  2025   * Function rproc_detach() calls __rproc_detach() in order to let a remote
eab58da78fe46f Mathieu Poirier 2021-02-11  2026   * processor know that services provided by the application processor are
eab58da78fe46f Mathieu Poirier 2021-02-11  2027   * no longer available.  From there it should be possible to remove the
eab58da78fe46f Mathieu Poirier 2021-02-11  2028   * platform driver and even power cycle the application processor (if the HW
eab58da78fe46f Mathieu Poirier 2021-02-11  2029   * supports it) without needing to switch off the remote processor.
eab58da78fe46f Mathieu Poirier 2021-02-11  2030   */
eab58da78fe46f Mathieu Poirier 2021-02-11  2031  int rproc_detach(struct rproc *rproc)
eab58da78fe46f Mathieu Poirier 2021-02-11  2032  {
eab58da78fe46f Mathieu Poirier 2021-02-11  2033  	struct device *dev = &rproc->dev;
eab58da78fe46f Mathieu Poirier 2021-02-11  2034  	int ret;
eab58da78fe46f Mathieu Poirier 2021-02-11  2035
eab58da78fe46f Mathieu Poirier 2021-02-11  2036  	ret = mutex_lock_interruptible(&rproc->lock);
eab58da78fe46f Mathieu Poirier 2021-02-11  2037  	if (ret) {
eab58da78fe46f Mathieu Poirier 2021-02-11  2038  		dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
eab58da78fe46f Mathieu Poirier 2021-02-11  2039  		return ret;
eab58da78fe46f Mathieu Poirier 2021-02-11  2040  	}
eab58da78fe46f Mathieu Poirier 2021-02-11  2041
eab58da78fe46f Mathieu Poirier 2021-02-11  2042  	if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) {
eab58da78fe46f Mathieu Poirier 2021-02-11  2043  		ret = -EPERM;
eab58da78fe46f Mathieu Poirier 2021-02-11  2044  		goto out;
eab58da78fe46f Mathieu Poirier 2021-02-11  2045  	}
eab58da78fe46f Mathieu Poirier 2021-02-11  2046
eab58da78fe46f Mathieu Poirier 2021-02-11  2047  	/* if the remote proc is still needed, bail out */
eab58da78fe46f Mathieu Poirier 2021-02-11  2048  	if (!atomic_dec_and_test(&rproc->power)) {
eab58da78fe46f Mathieu Poirier 2021-02-11  2049  		ret = -EBUSY;
eab58da78fe46f Mathieu Poirier 2021-02-11  2050  		goto out;
eab58da78fe46f Mathieu Poirier 2021-02-11  2051  	}
eab58da78fe46f Mathieu Poirier 2021-02-11  2052
eab58da78fe46f Mathieu Poirier 2021-02-11  2053  	ret = __rproc_detach(rproc);
eab58da78fe46f Mathieu Poirier 2021-02-11  2054  	if (ret) {
eab58da78fe46f Mathieu Poirier 2021-02-11  2055  		atomic_inc(&rproc->power);
eab58da78fe46f Mathieu Poirier 2021-02-11  2056  		goto out;
eab58da78fe46f Mathieu Poirier 2021-02-11  2057  	}
eab58da78fe46f Mathieu Poirier 2021-02-11  2058
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2059  	/*
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2060  	 * Install a clean resource table for re-attach while
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2061  	 * rproc->table_ptr is still valid.
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2062  	 */
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2063  	ret = rproc_reset_loaded_rsc_table(rproc);
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2064  	if (ret) {
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2065  		atomic_inc(&rproc->power);
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2066  		goto out;
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2067  	}
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2068
eab58da78fe46f Mathieu Poirier 2021-02-11  2069  	/* clean up all acquired resources */
eab58da78fe46f Mathieu Poirier 2021-02-11  2070  	rproc_resource_cleanup(rproc);
eab58da78fe46f Mathieu Poirier 2021-02-11  2071
eab58da78fe46f Mathieu Poirier 2021-02-11  2072  	/* release HW resources if needed */
eab58da78fe46f Mathieu Poirier 2021-02-11  2073  	rproc_unprepare_device(rproc);
eab58da78fe46f Mathieu Poirier 2021-02-11  2074
eab58da78fe46f Mathieu Poirier 2021-02-11  2075  	rproc_disable_iommu(rproc);
eab58da78fe46f Mathieu Poirier 2021-02-11  2076
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2077  	/* Free the copy of the resource table */
66e2fed7a4bb20 Mathieu Poirier 2021-02-11 @2078  	kfree(rproc->cached_table);
eab58da78fe46f Mathieu Poirier 2021-02-11  2079  	/* Follow the same sequence as in rproc_shutdown() */
eab58da78fe46f Mathieu Poirier 2021-02-11 @2080  	kfree(rproc->cached_table);
eab58da78fe46f Mathieu Poirier 2021-02-11  2081  	rproc->cached_table = NULL;
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2082  	rproc->clean_table = NULL;
eab58da78fe46f Mathieu Poirier 2021-02-11  2083  	rproc->table_ptr = NULL;
66e2fed7a4bb20 Mathieu Poirier 2021-02-11  2084
eab58da78fe46f Mathieu Poirier 2021-02-11  2085  out:
eab58da78fe46f Mathieu Poirier 2021-02-11  2086  	mutex_unlock(&rproc->lock);
eab58da78fe46f Mathieu Poirier 2021-02-11  2087  	return ret;
eab58da78fe46f Mathieu Poirier 2021-02-11  2088  }
eab58da78fe46f Mathieu Poirier 2021-02-11  2089  EXPORT_SYMBOL(rproc_detach);
eab58da78fe46f Mathieu Poirier 2021-02-11  2090

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: Type: application/gzip, Size: 24584 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-14 22:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 22:33 [PATCH v5 13/19] remoteproc: Properly deal with the resource table (fwd) Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).