Message ID | 20240302-linux-next-24-03-01-simple-clock-fixes-v1-1-25f348a5982b@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp245181dyc; Fri, 1 Mar 2024 16:53:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/cSK3EmLxoHCUQgmwXbTEZ7TLaI7tDW6Z3vYlbWrlaXUVinilE+6NVMbWDh6wYO9yQ+1TvHxQjZlr/tdm9Zjl2dElvQ== X-Google-Smtp-Source: AGHT+IHsZUWt+fqOC4KPG2a59gJMsQr2yrK5yoAMKqMaL99uzcPlbYAaegyDZRgjC1JD/9p7tFQe X-Received: by 2002:a05:6a20:789d:b0:1a1:1e8b:9044 with SMTP id d29-20020a056a20789d00b001a11e8b9044mr2671933pzg.50.1709340781690; Fri, 01 Mar 2024 16:53:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709340781; cv=pass; d=google.com; s=arc-20160816; b=LSHlv9U/+S0qpsyrp/UOtvEI16EKq5qDO+aUyBxxggnAo9jUyThvcMdT7iz6kBW3Ut Pm6oTMnjrRrF1KDSI0P1tpBY6cFJM98mey6p45PhMuDYGY70taemT8K6hjoLJQCgHXuO lVmZlnvtXp5LQzZliE/8U2oZt+nA1XnAnuQ4nkvExgjzRNw1vFmDSuyfCwIyVKKjNfeY hvs646t4DLaEIJvQoOvNG+x1ZFHM0ByYoj1sM27NGU7Wll5GbBlG4pw2zPqu/M38bqgh mLr83Nnkw5P1bV8CktLNB4D1wFWVsT/edEKfGjkbsjL81huhNnJucqmyyeoCpa0UlbH/ lKbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; fh=290Usqmf+OFVHYOw3XVbikicMu6UHvkJPuMGvmP27TQ=; b=Z0Cr07Efah8vog5Br3dF+38tfFvt+p8p5hxHCd0uwdBjDnk6ETQq/KgKX2UEajYO+G J1OlqcIiuCXxeegVs1xCOhR5xfCmPCycDWv55dftxZcNky4zHFdRh7UkXhgh5v2DOxEj U7LkXpUpFsWHPvXFzJ57cehsTxPmNgXGdUPT3NCoI2m2FMe12J0UNzUuyYI/pIGyu5DI 1oh3yYfTtO3i7kB73R80H/wsNcNrLEWnubay/ItqhDQXbLBWoWZK/JRArJya/rtGvVia EkJ5MZwAtg948WsUMneOZmUvb37xD4xTsyND2d6qYVnh9GX+hpRfvtVXzqu3JAv6vAXF sSmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ciwdgtcx; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u64-20020a637943000000b005dcd2963f82si4599359pgc.626.2024.03.01.16.53.01 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 16:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ciwdgtcx; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89271-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F4862852B2 for <ouuuleilei@gmail.com>; Sat, 2 Mar 2024 00:53:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42E18B66F; Sat, 2 Mar 2024 00:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ciwdgtcx" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98CA415B3 for <linux-kernel@vger.kernel.org>; Sat, 2 Mar 2024 00:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709340743; cv=none; b=HQVoC/bgKgdWCP3SkG3KE3A4emfcc3eI/SYZEl7zpeHcDFgmOtIhC0BzKviE7y0TxoIMkU+mPAvBd2Q+TlMzI3kt7kHrzMzPO0kiFsG2brFQmD1gt8PsD1B7eaKteuPwN9uztH+lGANEYK56cdTXshWGolZp+LFU2Dq38zEKj5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709340743; c=relaxed/simple; bh=i9zNt6rOlk75HZazBVwuQFbrGUUh1ujpF0qjhh1iKXA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IXZAgvtfWJh6KJb9dtLk16A1dW20ch+2lehJs8nRIePmSiOCJ/V9llMUzufZ11uvBMWmvlKhYSDZjXNkoQsp4QG04x0HpnC7OYvxdGHIcQ+FVYXyNEvZEJX95Wm/3b97XYomz8sY+31qYkBxSGIvfpWwvILWoCtJyXyUYtsm5ZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ciwdgtcx; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-412d29057a9so726335e9.1 for <linux-kernel@vger.kernel.org>; Fri, 01 Mar 2024 16:52:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709340740; x=1709945540; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; b=Ciwdgtcxa/fSIwfjDv5PEpnA12SP3Ng9piagaR7l7Ovt6t65i3JcZOvJqi/zFXd29D b71KOEy3u2LsjJFBCCJRlM8pH7oe6DSv3KW68ycHfPxaIenn2tq3MBfDGeefdR9SFfhx tw3QZtzDdma3CBg6Ucj8l3+a/H7jDXEABjR2BUZ2fsc+dNoZmO4+XsgPQNKobxKKh9ld 4NCIJfHOTrlvqKdTengK9/okDZjvdrSwhALXHhvgiZdYTVYK4ESkbh6VPxa91ufNVi/+ p1jQg6C9VVudSqxgOxZYa5ZTiTR2uTaeyFdA8/8PzZ47iqyy4G4vRZM1o2msMKo2eRyy kboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709340740; x=1709945540; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; b=ncF67h+OVuLVYGVE+4+LF+4BltV6h8hrEvC3cu9pdc85QP6ngEFwxCmbCeJeD/xKMZ thOaqk2GnA51ktW8a1NoLwttymSUjCS/GL2RM8uGciYV/87cvMW5o150uFul5enuRFNI gHvHL144OeclB6wK23pIzgYm1ZSHUz8BdwyL1cKZlZnQl/gM5mhYZh6EP0+Ukoutlkf0 d4SOsmLwiPRV1iDG7yayfZPwTaO9EaEREd1hO4c7JlmqpLP2KHUp/xlJyhVDlphs7q10 HpspleRr4YJ2meaT+r3JpSS9U9/0hIQJoi2p0ZGlFGEDp5Bv9yMMiKszSJeamCJbnpm0 7jBA== X-Forwarded-Encrypted: i=1; AJvYcCWCVczW6dNCUi56oreu5vqIsZF/QgoarkWiz1pWQm+/tyUmpWSjXfL3YmviC+PBPtFuFExoYAcuft7sDrrM/1qr48E+FN6eVDQxp1br X-Gm-Message-State: AOJu0YzERZYoN/qLRJvGfyF3SsbqxxjnTBS1uflKb+81BbLo9CaSbCM8 cuRIyJydlGOfICoHISmk1x1sc9aeMxZvE8qEG0X5KiCH6gkKg3qeFc5G5j1pskM= X-Received: by 2002:a05:600c:4448:b0:412:b0d3:49d9 with SMTP id v8-20020a05600c444800b00412b0d349d9mr3246722wmn.9.1709340739907; Fri, 01 Mar 2024 16:52:19 -0800 (PST) Received: from [127.0.1.1] ([176.61.106.68]) by smtp.gmail.com with ESMTPSA id f15-20020adffccf000000b0033dedd63382sm5865501wrs.101.2024.03.01.16.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 16:52:19 -0800 (PST) From: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Date: Sat, 02 Mar 2024 00:52:14 +0000 Subject: [PATCH 1/2] clk: Fix clk_core_get NULL dereference Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-1-25f348a5982b@linaro.org> References: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-0-25f348a5982b@linaro.org> In-Reply-To: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-0-25f348a5982b@linaro.org> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Bjorn Andersson <andersson@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Rajendra Nayak <quic_rjendra@quicinc.com>, Abel Vesa <abel.vesa@linaro.org> Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Bryan O'Donoghue <bryan.odonoghue@linaro.org> X-Mailer: b4 0.14-dev X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792373719747676699 X-GMAIL-MSGID: 1792373719747676699 |
Series |
clk: Fix a core error path and missing qcom camcc-x1e80100 enum
|
|
Commit Message
Bryan O'Donoghue
March 2, 2024, 12:52 a.m. UTC
It is possible for clk_core_get to dereference a NULL in the following
sequence:
clk_core_get()
of_clk_get_hw_from_clkspec()
__of_clk_get_hw_from_provider()
__clk_get_hw()
__clk_get_hw() can return NULL which is dereferenced by clk_core_get() at
hw->core.
Prior to commit dde4eff47c82 ("clk: Look for parents with clkdev based
clk_lookups") the check IS_ERR_OR_NULL() was performed which would have
caught the NULL.
Reading the description of this function it talks about returning NULL but
that cannot be so at the moment.
Update the function to check for hw before dereferencing it and return NULL
if hw is NULL.
Fixes: dde4eff47c82 ("clk: Look for parents with clkdev based clk_lookups")
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
drivers/clk/clk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a3bc7fb90d0f..25371c91a58f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -418,6 +418,9 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index) if (IS_ERR(hw)) return ERR_CAST(hw); + if (!hw) + return NULL; + return hw->core; }