Re: [PATCH] ASoC: rt298: Variable "val" and "buf" in rt298_jack_detect() could be uninitialized
From: Mark Brown
Date: Mon Jan 07 2019 - 11:29:11 EST
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?
Attachment:
signature.asc
Description: PGP signature