mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Yizhuo <yzhai003@ucr.edu>
Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu,
	Bard Liao <bardliao@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: rt298: Variable "val" and "buf" in rt298_jack_detect() could be uninitialized
Date: Mon, 7 Jan 2019 16:28:44 +0000	[thread overview]
Message-ID: <20190107162844.GK9570@sirena.org.uk> (raw)
In-Reply-To: <20190104215253.16278-1-yzhai003@ucr.edu>

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2019-01-07 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 21:52 Yizhuo
2019-01-07 16:28 ` Mark Brown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190107162844.GK9570@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=csong@cs.ucr.edu \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=yzhai003@ucr.edu \
    --cc=zhiyunq@cs.ucr.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®