[alsa-devel] [PATCH] ASoC: rt298: Variable "val" and "buf" in rt298_jack_detect() could be uninitialized

Mark Brown broonie at kernel.org
Mon Jan 7 17:28:44 CET 2019


On Fri, Jan 04, 2019 at 01:52:53PM -0800, Yizhuo wrote:

>  {
>  	struct snd_soc_dapm_context *dapm;
>  	unsigned int val, buf;
> +	int ret = 0;

It's bad practice to just initailize like this without a reason - it
tends to just mask actual cases where we miss error handling by ensuring
that it's always initialized.

>  			if (0x0070 == (val & 0x0070)) {
>  				*mic = true;
>  			} else {
>  				regmap_update_bits(rt298->regmap,
>  					RT298_CBJ_CTRL1, 0xfcc0, 0xe400);
>  				msleep(300);
> -				regmap_read(rt298->regmap,
> +				ret = regmap_read(rt298->regmap,
>  					RT298_CBJ_CTRL2, &val);
> +				if (ret)
> +					return ret;

We've started doing some writes to the device (which you've not added
checks for) here but then if the read fails we just bomb out with an
error code - are you sure that none of the writes need to be reverted?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20190107/3bc2adc3/attachment.sig>


More information about the Alsa-devel mailing list