2022-11-25 09:33:28

by Anastasia Belova

[permalink] [raw]
Subject: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable

Check clk for NULL before calling clk_enable_unlocked where clk
is dereferenced. There is such check in other implementations
of clk_enable.

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
Signed-off-by: Anastasia Belova <[email protected]>
---
arch/mips/bcm63xx/clk.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
index 6e6756e8fa0a..401140cf36d9 100644
--- a/arch/mips/bcm63xx/clk.c
+++ b/arch/mips/bcm63xx/clk.c
@@ -361,6 +361,9 @@ static struct clk clk_periph = {
*/
int clk_enable(struct clk *clk)
{
+ if (!clk)
+ return;
+
mutex_lock(&clocks_mutex);
clk_enable_unlocked(clk);
mutex_unlock(&clocks_mutex);
--
2.30.2


2022-11-25 14:56:17

by Jonas Gorski

[permalink] [raw]
Subject: Re: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable

On Fri, 25 Nov 2022 at 10:28, Anastasia Belova <[email protected]> wrote:
>
> Check clk for NULL before calling clk_enable_unlocked where clk
> is dereferenced. There is such check in other implementations
> of clk_enable.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
> Signed-off-by: Anastasia Belova <[email protected]>
> ---
> arch/mips/bcm63xx/clk.c | 3 +++
> 1 file changed, 3 insertions(+)

Makes sense, especially since clk_disable() already has a NULL check
(in case anybody else wonders).

Reviewed-by: Jonas Gorski <[email protected]>

2022-11-25 17:55:29

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable

On 25/11/22 10:26, Anastasia Belova wrote:
> Check clk for NULL before calling clk_enable_unlocked where clk
> is dereferenced. There is such check in other implementations
> of clk_enable.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
> Signed-off-by: Anastasia Belova <[email protected]>
> ---
> arch/mips/bcm63xx/clk.c | 3 +++
> 1 file changed, 3 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

2022-11-27 20:44:01

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable



On 11/25/2022 1:26 AM, Anastasia Belova wrote:
> Check clk for NULL before calling clk_enable_unlocked where clk
> is dereferenced. There is such check in other implementations
> of clk_enable.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
> Signed-off-by: Anastasia Belova <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian

2022-11-30 15:30:44

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable

Hi Anastasia,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.1-rc7 next-20221130]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Anastasia-Belova/MIPS-BCM63xx-Add-check-for-NULL-for-clk-in-clk_enable/20221125-173305
patch link: https://lore.kernel.org/r/20221125092601.3703-1-abelova%40astralinux.ru
patch subject: [PATCH] MIPS: BCM63xx: Add check for NULL for clk in clk_enable
config: mips-buildonly-randconfig-r002-20221128
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 6e4cea55f0d1104408b26ac574566a0e4de48036)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/881e6b8fb4e5b8a496f5083d3cc6873a3df339b4
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Anastasia-Belova/MIPS-BCM63xx-Add-check-for-NULL-for-clk-in-clk_enable/20221125-173305
git checkout 881e6b8fb4e5b8a496f5083d3cc6873a3df339b4
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash arch/mips/bcm63xx/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> arch/mips/bcm63xx/clk.c:365:3: error: non-void function 'clk_enable' should return a value [-Wreturn-type]
return;
^
1 error generated.


vim +/clk_enable +365 arch/mips/bcm63xx/clk.c

357
358
359 /*
360 * Linux clock API implementation
361 */
362 int clk_enable(struct clk *clk)
363 {
364 if (!clk)
> 365 return;
366
367 mutex_lock(&clocks_mutex);
368 clk_enable_unlocked(clk);
369 mutex_unlock(&clocks_mutex);
370 return 0;
371 }
372

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (2.44 kB)
config (112.75 kB)
Download all attachments