From patchwork Wed Dec 7 14:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 13067233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFDA4C4708E for ; Wed, 7 Dec 2022 14:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbiLGO3K (ORCPT ); Wed, 7 Dec 2022 09:29:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbiLGO2o (ORCPT ); Wed, 7 Dec 2022 09:28:44 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EBBE63C1; Wed, 7 Dec 2022 06:28:31 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 3F01F18641CD; Wed, 7 Dec 2022 17:28:27 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GISrUkIlnUMT; Wed, 7 Dec 2022 17:28:27 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id E683418641D2; Wed, 7 Dec 2022 17:28:26 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kN8wJLelYFIx; Wed, 7 Dec 2022 17:28:26 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id 3E16918641CD; Wed, 7 Dec 2022 17:28:26 +0300 (MSK) From: Anastasia Belova To: Thomas Bogendoerfer Cc: Anastasia Belova , Jonathan Cameron , Randy Dunlap , Florian Fainelli , Maxime Bizon , Ralf Baechle , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2 1/2] MIPS: BCM63xx: Add check for NULL for clk in clk_enable Date: Wed, 7 Dec 2022 17:28:23 +0300 Message-Id: <20221207142824.8706-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 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 --- 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); From patchwork Wed Dec 7 14:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 13067234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8471C63703 for ; Wed, 7 Dec 2022 14:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbiLGO3L (ORCPT ); Wed, 7 Dec 2022 09:29:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbiLGO2o (ORCPT ); Wed, 7 Dec 2022 09:28:44 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227EA56EC0; Wed, 7 Dec 2022 06:28:34 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 7390018643B9; Wed, 7 Dec 2022 17:28:32 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cMC_BiZcTg-y; Wed, 7 Dec 2022 17:28:32 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 2722D18643BE; Wed, 7 Dec 2022 17:28:32 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IfQygreVYS-r; Wed, 7 Dec 2022 17:28:32 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id 8132D18643B9; Wed, 7 Dec 2022 17:28:31 +0300 (MSK) From: Anastasia Belova To: Thomas Bogendoerfer Cc: Anastasia Belova , Jonathan Cameron , Randy Dunlap , Florian Fainelli , Maxime Bizon , Ralf Baechle , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, kernel test robot Subject: [PATCH v2 2/2] MIPS: BCM63xx: Add check for NULL for clk in clk_enable Date: Wed, 7 Dec 2022 17:28:24 +0300 Message-Id: <20221207142824.8706-2-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221207142824.8706-1-abelova@astralinux.ru> References: <20221207142824.8706-1-abelova@astralinux.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Errors from previous version of patch fixed. 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.") Reported-by: kernel test robot Signed-off-by: Anastasia Belova --- arch/mips/bcm63xx/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index 401140cf36d9..cf303d6e6693 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -362,7 +362,7 @@ static struct clk clk_periph = { int clk_enable(struct clk *clk) { if (!clk) - return; + return 0; mutex_lock(&clocks_mutex); clk_enable_unlocked(clk);