diff mbox

[RFC] ASoC: rsnd: Add missing initialization of ADG req_rate

Message ID 1446044628-16924-1-git-send-email-geert+renesas@glider.be (mailing list archive)
State Accepted
Commit 8b27418f300cafbdbbb8cfa9c29d398ed34d6723
Headers show

Commit Message

Geert Uytterhoeven Oct. 28, 2015, 3:03 p.m. UTC
If the "clock-frequency" DT property is not found, req_rate is used
uninitialized, and the "audio_clkout" clock will be created with an
arbitrary clock rate.

This uninitialized kernel stack data may leak to userspace through
/sys/kernel/debug/clk/clk_summary, cfr. the value in the "rate" column:

       clock     enable_cnt  prepare_cnt        rate   accuracy   phase
    --------------------------------------------------------------------
     audio_clkout         0            0  4001836240          0 0

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Should the absence of this property be considered an error?

Documentation/devicetree/bindings/sound/renesas,rsnd.txt states that
both "#clock-cells" and "clock-frequency" are required properties, but
none of the R-Car Gen1 and Gen2 DTSes seem to have them?
---
 sound/soc/sh/rcar/adg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kuninori Morimoto Oct. 28, 2015, 11:57 p.m. UTC | #1
Hi Geert

> If the "clock-frequency" DT property is not found, req_rate is used
> uninitialized, and the "audio_clkout" clock will be created with an
> arbitrary clock rate.
> 
> This uninitialized kernel stack data may leak to userspace through
> /sys/kernel/debug/clk/clk_summary, cfr. the value in the "rate" column:
> 
>        clock     enable_cnt  prepare_cnt        rate   accuracy   phase
>     --------------------------------------------------------------------
>      audio_clkout         0            0  4001836240          0 0
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---

Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

> Should the absence of this property be considered an error?
> 
> Documentation/devicetree/bindings/sound/renesas,rsnd.txt states that
> both "#clock-cells" and "clock-frequency" are required properties, but
> none of the R-Car Gen1 and Gen2 DTSes seem to have them?

This clkout is option for each board
will fix
Mark Brown Oct. 28, 2015, 11:59 p.m. UTC | #2
On Wed, Oct 28, 2015 at 04:03:48PM +0100, Geert Uytterhoeven wrote:

> If the "clock-frequency" DT property is not found, req_rate is used
> uninitialized, and the "audio_clkout" clock will be created with an
> arbitrary clock rate.

I'd expect that if we support a missing clock frequency property we'd
read the state back from the hardware.
diff mbox

Patch

diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
index 2a5b3a293cd243db..b123734f9fbdabd9 100644
--- a/sound/soc/sh/rcar/adg.c
+++ b/sound/soc/sh/rcar/adg.c
@@ -437,7 +437,7 @@  static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
 	struct device *dev = rsnd_priv_to_dev(priv);
 	struct device_node *np = dev->of_node;
 	u32 ckr, rbgx, rbga, rbgb;
-	u32 rate, req_rate, div;
+	u32 rate, req_rate = 0, div;
 	uint32_t count = 0;
 	unsigned long req_48kHz_rate, req_441kHz_rate;
 	int i;