From mboxrd@z Thu Jan 1 00:00:00 1970 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 922FFC4332F for ; Thu, 12 May 2022 16:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356233AbiELQFN (ORCPT ); Thu, 12 May 2022 12:05:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356241AbiELQFL (ORCPT ); Thu, 12 May 2022 12:05:11 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D38AA62BF4 for ; Thu, 12 May 2022 09:05:08 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 430005C01E5; Thu, 12 May 2022 12:05:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 May 2022 12:05:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1652371508; x=1652457908; bh=MX qC38DcKa37Vd75cbNyJjb6wJVeHddhwpvwyzO4EFo=; b=p7b68L7FSV5B3kkBEM 57gE+7N19MWbQ514qOZ1SNObfE8uzuKGFDo4Di77kqgcXwChnOXxC3VL4BkAzF7J cD0FVyR3FslaPBQuMiQ2N/Mjpxz1Bey3AiaCX2KYiRshGhDQC2PRnKKd2yq8V6GP ZGze9r42vwC4UegFWGRoaYjzVuJEHc3luzF2KdEfvI3KVVIMBig6QN38bIhVrg7b DCxRkVd8icmb7WnJCUWOrun5JrTkYkQTb9JpPxT1tpkEEumnvxmCBeM4inr5e4UX I9rzwRA1uagLZXhojcSVAfoJ8iaiaRD/yKL1rrLQVgkCL22PqETcoiY12YTG2td3 Evuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652371508; x=1652457908; bh=MXqC38DcKa37Vd75cbNyJjb6wJVeHddhwpv wyzO4EFo=; b=qqAq1utUHBLEZrIf+NsLt7dEmxV+DM+B3hyvNG+CJAlSWaoJMhz ypQ3EDh4wfLXLLTdrd1fkKENn8hnehnFvNeMwHwZ1osKrjUDLfnSR7s8wOlaSHwZ tL9Pqw2VJXODjQyUCu2egkfZMwqEowjMPYpogk5cSZYEoS7GxDTh/9fhnSfvdBMG OydScXEkqkRelp4SFVrzqj+M8BrVuMx8Rd9oIxuBhM9TlIn8aZe9lmwty27vNqDM dC1NH+hKTxFMdsGCqaNo34cyED7sLDC1kAk7zEuwTyMFx74Ydq3n8ka/PmRXSowu mQLTnAE3kKrvlC0i2yHm21dlE9srFL+33zQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgeejgdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepleekfeetudfhkeejiefhtedugfeuvdevkeekteetkefhkefhtdelgfefuddv jefhnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 May 2022 12:05:07 -0400 (EDT) From: Maxime Ripard To: Mike Turquette , Stephen Boyd , linux-clk@vger.kernel.org Cc: Naresh Kamboju , Alexander Stein , Jerome Brunet , Dmitry Baryshkov , Marek Szyprowski , Yassine Oudjana , Tony Lindgren , Neil Armstrong , Maxime Ripard Subject: [PATCH v4 24/28] clk: Test the clock pointer in clk_hw_get_name() Date: Thu, 12 May 2022 18:04:08 +0200 Message-Id: <20220512160412.1317123-25-maxime@cerno.tech> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220512160412.1317123-1-maxime@cerno.tech> References: <20220512160412.1317123-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Unlike __clk_get_name(), clk_hw_get_name() doesn't test wether passed clk_hw pointer is NULL or not and dereferences it directly. This can then lead to NULL pointer dereference. Let's make sure the pointer isn't NULL before dereferencing it. Tested-by: Alexander Stein # imx8mp Tested-by: Marek Szyprowski # exynos4210, meson g12b Signed-off-by: Maxime Ripard --- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d953ca61ea38..364e6baa3d1c 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -262,7 +262,7 @@ EXPORT_SYMBOL_GPL(__clk_get_name); const char *clk_hw_get_name(const struct clk_hw *hw) { - return hw->core->name; + return !hw ? NULL : hw->core->name; } EXPORT_SYMBOL_GPL(clk_hw_get_name); -- 2.36.1