From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F956749A for ; Thu, 12 Jan 2023 14:03:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 356F3C433D2; Thu, 12 Jan 2023 14:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673532237; bh=MjM81aUBAFOwzo3m9Wb7B2rUEGryCV94JBI1CmLi4oA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8aVtumftQo7tHDokocDCCqr10gQBriM/8W9E8+GbGwD5o9mw0q3NoAlQW3FB8AO0 iWEyAOLlqVexNPVFP8nazxP0mRCyF7DEPYlNNhwRQH+Ec4cZMyOFIsgD6C423DiUbL kbftG28ZJf+2bVn1s7vAA6ImR1pKVE6P/GhWbTJM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Anastasia Belova , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Florian Fainelli , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.10 095/783] MIPS: BCM63xx: Add check for NULL for clk in clk_enable Date: Thu, 12 Jan 2023 14:46:51 +0100 Message-Id: <20230112135528.597722785@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112135524.143670746@linuxfoundation.org> References: <20230112135524.143670746@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anastasia Belova [ Upstream commit ee9ef11bd2a59c2fefaa0959e5efcdf040d7c654 ] 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: Philippe Mathieu-Daudé Acked-by: Florian Fainelli Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- 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 dcfa0ea912fe..f183c45503ce 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -361,6 +361,8 @@ static struct clk clk_periph = { */ int clk_enable(struct clk *clk) { + if (!clk) + return 0; mutex_lock(&clocks_mutex); clk_enable_unlocked(clk); mutex_unlock(&clocks_mutex); -- 2.35.1