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] In function rt274_i2c_probe(), if the regmap_read fails. The variable "val" could leave uninitialized but used in if statement.
Date: Thu, 3 Jan 2019 13:10:33 +0000	[thread overview]
Message-ID: <20190103131033.GU1846@sirena.org.uk> (raw)
In-Reply-To: <20190103023839.15314-1-yzhai003@ucr.edu>

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

On Wed, Jan 02, 2019 at 06:38:39PM -0800, Yizhuo wrote:

>  	int ret;
> -	unsigned int val;
> +	unsigned int val = ~0;
>  

This just shuts warnings up which may mask further problem, it is better
to just leave it and fix the users.

> -	regmap_read(rt274->regmap,
> +	ret = regmap_read(rt274->regmap,
>  		RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
> -	if (val != RT274_VENDOR_ID) {
> +	if (ret || val != RT274_VENDOR_ID) {
>  		dev_err(&i2c->dev,
>  			"Device with ID register %#x is not rt274\n", val);
>  		return -ENODEV;

If the read returned an error we should pass back the error code we got
from it, not mask it with another error code.  This is especially true
here where the error message would be very misleading if there's a
problem with I/O.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2019-01-03 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03  2:38 Yizhuo
2019-01-03 13:10 ` 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=20190103131033.GU1846@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®