Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2493245rwb; Fri, 9 Dec 2022 02:51:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sxYizREO0amt8y9grw193Hv1hY+042l2PVlXwPr576eV0k1ZHnqEvU+fW71nVLHxCEzVJ X-Received: by 2002:a17:906:3f90:b0:7ad:943a:4da0 with SMTP id b16-20020a1709063f9000b007ad943a4da0mr4448174ejj.21.1670583106473; Fri, 09 Dec 2022 02:51:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670583106; cv=none; d=google.com; s=arc-20160816; b=a4mJRnH56y7y+CXBs551xatl97V5Hg45urKLTKV1A2tC/ZRvxE10XQ+KwE/UKPrIsO O6i67NNQMSOSkmgiSdRDK+CjPIwfK53dD1qecIkU2FwE9//G0QedSN4g1OEoDm6Thrzn EQzJcxDQXSSoM47VwcIhjoJd1Pk+a2yRCVtbJhKKMBkSrPIj0xzpH/THgtEv31Kn6p3f IGHPsYA9nr9oqflWvVwmwein2Kufkvf89ELZ02c2cqwkmq7KLd7VMirPbguVR+93jF/K pUeXKskBEIv3o8OCsIessQujFWQIKfHcKgTFq+jplHv3v90fT4OlvbeMfs0JiWB8sakD dijw== 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=eA5m4zPK7oczBLsxnq26ekj7kLTVDdDJLeSr9JbIW2A=; b=t0gZ6vGmKnSUeJDNr1+YMt7MaXXbsAvqSi8PNY6e8UvnUMaglLzC/3LQUU8Own91iq 2+68pNv17293cPgpIgNwCsL7TH4SlZLKJn7lsDI7ce/LG242nejNQ2dqmHbwMTwIbETI oSMKI3izAlThs5KgyjUWy7J6nFFsHSM0X2PRoe8WMl14XxwaonOQWbT/yLWO6swlgiic GWvH+wp7W67s5jtTAgoTlIX5MajP1OgHd5LH24Bw98w+nd1MNVFxXeMTbPSp2SorMscI ad12qPjsNtZpRySySmE7kObfldqRtObvwtFk/78Mxd7eaKeh34UgMBRPKWyr28oIh5km zCpQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xb4-20020a170907070400b007c115fb9d63si882536ejb.392.2022.12.09.02.51.29; Fri, 09 Dec 2022 02:51:46 -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 S229640AbiLIKGB (ORCPT + 74 others); Fri, 9 Dec 2022 05:06:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiLIKF7 (ORCPT ); Fri, 9 Dec 2022 05:05:59 -0500 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A35A5196; Fri, 9 Dec 2022 02:05:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 4AFAE186418E; Fri, 9 Dec 2022 13:05:54 +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 VxhB5KV63KKr; Fri, 9 Dec 2022 13:05:54 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 00DC318643B4; Fri, 9 Dec 2022 13:05:53 +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 ldQXrwzzovs9; Fri, 9 Dec 2022 13:05:53 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.20]) by mail.astralinux.ru (Postfix) with ESMTPSA id 65908186418E; Fri, 9 Dec 2022 13:05:53 +0300 (MSK) From: Anastasia Belova To: Thomas Bogendoerfer Cc: Anastasia Belova , Randy Dunlap , Florian Fainelli , Jonathan Cameron , Ralf Baechle , Maxime Bizon , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v3] MIPS: BCM63xx: Add check for NULL for clk in clk_enable Date: Fri, 9 Dec 2022 13:05:50 +0300 Message-Id: <20221209100550.30470-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 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 --- v2: Fix errors reported by kernel test robot . v3: Merge several patches into single one. arch/mips/bcm63xx/clk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index 6e6756e8fa0a..86a6e2590866 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -361,6 +361,8 @@ static struct clk clk_periph =3D { */ int clk_enable(struct clk *clk) { + if (!clk) + return 0; mutex_lock(&clocks_mutex); clk_enable_unlocked(clk); mutex_unlock(&clocks_mutex); --=20 2.30.2