From patchwork Fri Nov 25 09:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 25887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3879395wrr; Fri, 25 Nov 2022 01:27:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bEs/nOWCZ40d0rxKzjGdlwJfgflcmiGI0Kz1+3FKw9vpFEPtNEfmb1fkF8kIRlXiRx7dT X-Received: by 2002:a62:868a:0:b0:56e:3a98:f02 with SMTP id x132-20020a62868a000000b0056e3a980f02mr25556290pfd.53.1669368465180; Fri, 25 Nov 2022 01:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669368465; cv=none; d=google.com; s=arc-20160816; b=iw/joEEjaexYqK9Nq/GWjtvf2BNpKW3wTS53ljVrL5SnQDEeeJTfp5yBUBt7pZxdLu hnlfRgjbmyphq1uwMk9HzgG1b6DsKJeKSDTsazz4NamOnqJPnL3bFa65FSdEpn9KjuR9 61r+qDNJr/3yjfSc0gbQzcwq9sWf3UBGS2jo0Hk0Qg0NjBLcQKEtx47hz7iK+dvS0w0V vbT0E+SBcb0dcSUhq2XghdpK9vfRLLFQNPETrW/6MbbQ3qdLkbDjzcPaj5ZkHtErUXlX L33QzQlX7oCQlIiwxBBPqBaLjORkI2O5Hh757hXxCT6r2mAF69B0jLj9PdB1+6L0NGuf wNvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=btd5BCK74T3HCrkYFswHCg2SlYH1HJVpAZMxqiNwUIs=; b=EFal5VIO8dOMOcjaU20R+i+7TiCbILba5jVEM0X7aDtvVltpT+IaYoC9JBydD8oYoq aNrgYCzk5tVU/OAGCD/whiHkksnSVd0fXr3SXckD9rV4PS6n+TZGACwFxmBw7RsH70P+ xKyuud7CM0d3HO9U7pA0nYfXMdISITWlGR8aLTqkF/d0D+n0E5kK35gzifPolKV5+JKq OnxybPoVc3MxKuorUVkS8VFg7pH6SnJ3+KqeqvYU127tY2drqjQB0tIJYMFzdOXo5adF BeFDQDdLk65j8mLMqK4/UYQJJ5N6VOUQWPOrfyFjmPSVydFrSQWEAzSrwpYsdGPVvV82 QXrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a17090274c200b0017ab01a9cb4si3117707plt.317.2022.11.25.01.27.32; Fri, 25 Nov 2022 01:27:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiKYJ0p (ORCPT + 99 others); Fri, 25 Nov 2022 04:26:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiKYJ0Y (ORCPT ); Fri, 25 Nov 2022 04:26:24 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA823AC27; Fri, 25 Nov 2022 01:26:12 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id F30D11864518; Fri, 25 Nov 2022 12:26:08 +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 xpKOhFxgqLgb; Fri, 25 Nov 2022 12:26:08 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 917281864545; Fri, 25 Nov 2022 12:26:08 +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 Im-HyczXp3ix; Fri, 25 Nov 2022 12:26:08 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id DCECD1864435; Fri, 25 Nov 2022 12:26:07 +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] MIPS: BCM63xx: Add check for NULL for clk in clk_enable Date: Fri, 25 Nov 2022 12:26:01 +0300 Message-Id: <20221125092601.3703-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750459707723777099?= X-GMAIL-MSGID: =?utf-8?q?1750459707723777099?= 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 Reviewed-by: Jonas Gorski Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Florian Fainelli --- 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);