lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 1 Mar 2022 12:44:12 +0000
From:   Mark Brown <broonie@...nel.org>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc:     lgirdwood@...il.com, perex@...ex.cz, tiwai@...e.com,
        ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
        kafai@...com, songliubraving@...com, yhs@...com,
        john.fastabend@...il.com, kpsingh@...nel.org, f.suligoi@...m.it,
        kuninori.morimoto.gx@...esas.com, alsa-devel@...a-project.org,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        bpf@...r.kernel.org
Subject: Re: [PATCH] ASoC: fsi: Add check for clk_enable

On Tue, Mar 01, 2022 at 03:39:49PM +0800, Jiasheng Jiang wrote:
> As the potential failure of the clk_enable(),
> it should be better to check it and return error
> if fails.

> -		clk_enable(clock->xck);
> -		clk_enable(clock->ick);
> -		clk_enable(clock->div);
> +		ret = clk_enable(clock->xck);
> +		if (ret)
> +			goto err;
> +		ret = clk_enable(clock->ick);
> +		if (ret)
> +			goto err;
> +		ret = clk_enable(clock->div);
> +		if (ret)
> +			goto err;
>  
>  		clock->count++;
>  	}
>  
>  	return ret;
> +
> +err:
> +	clk_disable(clock->xck);
> +	clk_disable(clock->ick);
> +	clk_disable(clock->div);

You need separate labels for each enable so that we don't end up
disabling clocks we didn't enable, that would also be a bug.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ