From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0093.outbound.protection.outlook.com ([104.47.41.93]:53619 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728320AbeIOGtO (ORCPT ); Sat, 15 Sep 2018 02:49:14 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Mikko Perttunen , Stephen Boyd , Sasha Levin Subject: [PATCH AUTOSEL 4.18 92/92] clk: tegra: bpmp: Don't crash when a clock fails to register Date: Sat, 15 Sep 2018 01:31:00 +0000 Message-ID: <20180915012944.179481-91-alexander.levin@microsoft.com> References: <20180915012944.179481-1-alexander.levin@microsoft.com> In-Reply-To: <20180915012944.179481-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Mikko Perttunen [ Upstream commit f7b3182232c82bb9769e2d5471d702bae2972d2b ] When registering clocks, we just skip any that fail to register (leaving a NULL hole in the clock table). However, our of_xlate function still tries to dereference each entry while looking for the clock with the requested id, causing a crash if any clocks failed to register. Add a check to of_xlate to skip any NULL clocks. Signed-off-by: Mikko Perttunen Acked-by: Jon Hunter Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/tegra/clk-bpmp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c index a896692b74ec..01dada561c10 100644 --- a/drivers/clk/tegra/clk-bpmp.c +++ b/drivers/clk/tegra/clk-bpmp.c @@ -586,9 +586,15 @@ static struct clk_hw *tegra_bpmp_clk_of_xlate(struct o= f_phandle_args *clkspec, unsigned int id =3D clkspec->args[0], i; struct tegra_bpmp *bpmp =3D data; =20 - for (i =3D 0; i < bpmp->num_clocks; i++) - if (bpmp->clocks[i]->id =3D=3D id) - return &bpmp->clocks[i]->hw; + for (i =3D 0; i < bpmp->num_clocks; i++) { + struct tegra_bpmp_clk *clk =3D bpmp->clocks[i]; + + if (!clk) + continue; + + if (clk->id =3D=3D id) + return &clk->hw; + } =20 return NULL; } --=20 2.17.1