Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5daf7be authored by Banajit Goswami's avatar Banajit Goswami
Browse files

ASoC: audio-ext-clk: fix number of clocks for lnbb clk



ln_bb_clk2 is defined in a different array than the rest of the
clocks. Use the right array to calculate the number of clocks in
that array to avoid possible over allocation of memory.

Change-Id: I7e68e15d037810840605a7d86dd54eaf6c6cc427
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent 3f05156a
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -496,17 +496,18 @@ static int audio_ref_clk_probe(struct platform_device *pdev)
	if (!clk_data)
		goto err_gpio;


	clk_gpio = of_get_named_gpio(pdev->dev.of_node,
				     "qcom,audio-ref-clk-gpio", 0);
	if (clk_gpio > 0) {
		clk_data->clk_num = ARRAY_SIZE(audio_msm_hws);
		clk_data->clks = devm_kzalloc(&pdev->dev,
				clk_data->clk_num * sizeof(struct clk *),
					clk_data->clk_num *
					sizeof(struct clk *),
					GFP_KERNEL);
		if (!clk_data->clks)
			goto err_clk;


	clk_gpio = of_get_named_gpio(pdev->dev.of_node,
				     "qcom,audio-ref-clk-gpio", 0);
	if (clk_gpio > 0) {
		for (i = 0; i < ARRAY_SIZE(audio_msm_hws); i++) {
			audio_clk = devm_clk_register(dev, audio_msm_hws[i]);
			if (IS_ERR(audio_clk)) {
@@ -518,6 +519,14 @@ static int audio_ref_clk_probe(struct platform_device *pdev)
			clk_data->clks[i] = audio_clk;
		}
	} else {
		clk_data->clk_num = ARRAY_SIZE(audio_msm_hws1);
		clk_data->clks = devm_kzalloc(&pdev->dev,
					clk_data->clk_num *
					sizeof(struct clk *),
					GFP_KERNEL);
		if (!clk_data->clks)
			goto err_clk;

		for (i = 0; i < ARRAY_SIZE(audio_msm_hws1); i++) {
			audio_clk = devm_clk_register(dev, audio_msm_hws1[i]);
			if (IS_ERR(audio_clk)) {