Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2024 14:45:50 GMT
From:      Tom Jones <thj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 855c3dacfc6a - main - imx clk: Skip reconfiguring the clock if we don't have a new best_parent
Message-ID:  <202409161445.48GEjolf090644@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by thj:

URL: https://cgit.FreeBSD.org/src/commit/?id=855c3dacfc6a1565a75086e64a154dece3ccf5fa

commit 855c3dacfc6a1565a75086e64a154dece3ccf5fa
Author:     Tom Jones <thj@FreeBSD.org>
AuthorDate: 2024-09-16 14:43:31 +0000
Commit:     Tom Jones <thj@FreeBSD.org>
CommitDate: 2024-09-16 14:45:26 +0000

    imx clk: Skip reconfiguring the clock if we don't have a new best_parent
    
    imx_clk_composite_find_best_parent can fail, when it does for all the
    clocks checked we attempt to configure an uninitialized best_parent
    leading to a panic.
    
    Initialize best_parent and skip reconfiguring the clock if we don't find
    a new best_parent to use.
    
    Reviewed By: manu
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D46662
---
 sys/arm64/freescale/imx/clk/imx_clk_composite.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sys/arm64/freescale/imx/clk/imx_clk_composite.c b/sys/arm64/freescale/imx/clk/imx_clk_composite.c
index 1d5ab5908d8c..3d2ef06fb8a2 100644
--- a/sys/arm64/freescale/imx/clk/imx_clk_composite.c
+++ b/sys/arm64/freescale/imx/clk/imx_clk_composite.c
@@ -217,6 +217,7 @@ imx_clk_composite_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout
 	p_names = clknode_get_parent_names(clk);
 
 	best_diff = 0;
+	best_parent = -1;
 
 	for (p_idx = 0; p_idx != clknode_get_parents_num(clk); p_idx++) {
 		p_clk = clknode_find_by_name(p_names[p_idx]);
@@ -243,6 +244,10 @@ imx_clk_composite_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout
 	if (best_diff == INT64_MAX)
 		return (ERANGE);
 
+	/* If we didn't find a new best_parent just return */
+	if (best_parent == -1)
+		return (0);
+
 	if ((flags & CLK_SET_DRYRUN) != 0) {
 		*fout = best;
 		return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409161445.48GEjolf090644>