From: Matthias Kaehlcke <mka@chromium.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: Rob Herring <robh@kernel.org>, Andy Gross <agross@kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Stephen Boyd <sboyd@codeaurora.org>,
Jeffrey Hugo <jhugo@codeaurora.org>,
Taniya Das <tdas@codeaurora.org>,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
harigovi@codeaurora.org, kalyan_t@codeaurora.org,
Mark Rutland <mark.rutland@arm.com>,
linux-clk@vger.kernel.org, hoegsberg@chromium.org,
Michael Turquette <mturquette@baylibre.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 01/10] clk: qcom: rcg2: Don't crash if our parent can't be found; return an error
Date: Tue, 28 Jan 2020 09:43:02 -0800 [thread overview]
Message-ID: <20200128174302.GA46072@google.com> (raw)
In-Reply-To: <20200124144154.v2.1.I7487325fe8e701a68a07d3be8a6a4b571eca9cfa@changeid>
On Fri, Jan 24, 2020 at 02:42:16PM -0800, Douglas Anderson wrote:
> When I got my clock parenting slightly wrong I ended up with a crash
> that looked like this:
>
> Unable to handle kernel NULL pointer dereference at virtual
> address 0000000000000000
> ...
> pc : clk_hw_get_rate+0x14/0x44
> ...
> Call trace:
> clk_hw_get_rate+0x14/0x44
> _freq_tbl_determine_rate+0x94/0xfc
> clk_rcg2_determine_rate+0x2c/0x38
> clk_core_determine_round_nolock+0x4c/0x88
> clk_core_round_rate_nolock+0x6c/0xa8
> clk_core_round_rate_nolock+0x9c/0xa8
> clk_core_set_rate_nolock+0x70/0x180
> clk_set_rate+0x3c/0x6c
> of_clk_set_defaults+0x254/0x360
> platform_drv_probe+0x28/0xb0
> really_probe+0x120/0x2dc
> driver_probe_device+0x64/0xfc
> device_driver_attach+0x4c/0x6c
> __driver_attach+0xac/0xc0
> bus_for_each_dev+0x84/0xcc
> driver_attach+0x2c/0x38
> bus_add_driver+0xfc/0x1d0
> driver_register+0x64/0xf8
> __platform_driver_register+0x4c/0x58
> msm_drm_register+0x5c/0x60
> ...
>
> It turned out that clk_hw_get_parent_by_index() was returning NULL and
> we weren't checking. Let's check it so that we don't crash.
>
> Fixes: ac269395cdd8 ("clk: qcom: Convert to clk_hw based provider APIs")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> I haven't gone back and tried to reproduce this same crash on older
> kernels, but I'll put the blame on commit ac269395cdd8 ("clk: qcom:
> Convert to clk_hw based provider APIs"). Before that if we got a NULL
> parent back it was fine and dandy since a NULL "struct clk" is valid
> to use but a NULL "struct clk_hw" is not.
>
> Changes in v2:
> - Patch ("clk: qcom: rcg2: Don't crash...") new for v2.
>
> drivers/clk/qcom/clk-rcg2.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> index da045b200def..9098001ac805 100644
> --- a/drivers/clk/qcom/clk-rcg2.c
> +++ b/drivers/clk/qcom/clk-rcg2.c
> @@ -218,6 +218,9 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,
>
> clk_flags = clk_hw_get_flags(hw);
> p = clk_hw_get_parent_by_index(hw, index);
> + if (!p)
> + return -EINVAL;
> +
> if (clk_flags & CLK_SET_RATE_PARENT) {
> rate = f->freq;
> if (f->pre_div) {
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
next prev parent reply other threads:[~2020-01-28 17:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-24 22:42 [PATCH v2 00/10] clk: qcom: Fix parenting for dispcc/gpucc/videocc Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 01/10] clk: qcom: rcg2: Don't crash if our parent can't be found; return an error Douglas Anderson
2020-01-28 17:43 ` Matthias Kaehlcke [this message]
2020-01-24 22:42 ` [PATCH v2 02/10] dt-bindings: clock: Fix qcom,dispcc bindings for sdm845/sc7180 Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 03/10] arm64: dts: qcom: sdm845: Add the missing clocks on the dispcc Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 04/10] dt-bindings: clock: Fix qcom,gpucc bindings for sdm845/sc7180/msm8998 Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 05/10] clk: qcom: Fix sc7180 dispcc parent data Douglas Anderson
2020-01-28 5:53 ` Taniya Das
2020-01-28 16:33 ` Doug Anderson
2020-01-29 0:51 ` Stephen Boyd
2020-01-30 21:19 ` Doug Anderson
2020-01-24 22:42 ` [PATCH v2 06/10] arm64: dts: qcom: sdm845: Add the missing clocks on the gpucc Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 07/10] clk: qcom: Fix sc7180 gpucc parent data Douglas Anderson
2020-01-28 5:55 ` Taniya Das
2020-01-28 16:37 ` Doug Anderson
2020-01-24 22:42 ` [PATCH v2 08/10] dt-bindings: clock: Cleanup qcom,videocc bindings for sdm845/sc7180 Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 09/10] arm64: dts: qcom: sdm845: Add the missing clock on the videocc Douglas Anderson
2020-01-24 22:42 ` [PATCH v2 10/10] arm64: dts: sc7180: Add clock controller nodes Douglas Anderson
2020-01-28 5:58 ` Taniya Das
2020-01-28 16:40 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200128174302.GA46072@google.com \
--to=mka@chromium.org \
--cc=agross@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=harigovi@codeaurora.org \
--cc=hoegsberg@chromium.org \
--cc=jhugo@codeaurora.org \
--cc=kalyan_t@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@codeaurora.org \
--cc=tdas@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).