Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp875111imu; Thu, 3 Jan 2019 08:39:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RTWoIbA77bV+dQw+lHh6vgBQGnf7hYH3/5/Y6PmBunGIYcGHBqnFqWtDBdodnaKyFowNm X-Received: by 2002:a17:902:3281:: with SMTP id z1mr48402391plb.296.1546533545080; Thu, 03 Jan 2019 08:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546533545; cv=none; d=google.com; s=arc-20160816; b=DVi2fK8cxJtGougKed7tfrERjIgSUAl8qsuH1VLhzN2g5O0QXnJFEORvKMHoOlIEz0 ggYMCA9ZqgEhJa/tFBPqbqRv8rw81a0aaHwdMWyah5+/NWOOkbIcxKnKiDwM4O0xpoXr U66YNhP9KNWY57H2aPZvRtErBl00ItACCj0qyRlpkEcXthjxZJW6YQnytLBUQBOZDrIx lpLnXgOp0ZOyb+/t/CPRmBQFy6pwifjlvEb85LGzrGouz9Y21tPQhNDUyZs1kGLZvcaV TICVNdIMwYmCmkB2Y56/slLTcpaioLfhgTO3axip9Iq4PveZdp8AZ/60dSggynXdY1Q+ zUBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2eDQ4bVlRXsycjE1X7GXc2V755O1XKU4dZz7BmFpzFQ=; b=0lcxaq/VNmwD5FChv3L4OAtskuBi5a+31TiQyGRVZoXjJNLmHGlJh9AadhRQQ1HhwT BeauG+jpuTzWV1CCUFrYRtkauia8bdwEHbY2q46YJoHeKre8uZ0kcJbI0TX1NaC3NDfe tPQFp9E/Ytrwm4lhnjsDXcCzjxTnq/fgVW+HP7d0UOZOoUu9LMlo9ho1RrdCBx+dF7zc CDFPpC5Mfxwrp6S2KLRkNE0ipAaPnMzFvcd8o9XYR/ec//3D4jKobaDJ3E9psE+oJR2h +90kaQSQQCV1ajRjbDGCHtz4JDiUCpJxOQC/N+iP1EQZuQ2HAEuYHAT0hfgJKdKLVH+v KJwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=HyxSUxL4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d14si53756143pgn.390.2019.01.03.08.38.50; Thu, 03 Jan 2019 08:39:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=HyxSUxL4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730731AbfACNLX (ORCPT + 99 others); Thu, 3 Jan 2019 08:11:23 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:36424 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730675AbfACNLX (ORCPT ); Thu, 3 Jan 2019 08:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2eDQ4bVlRXsycjE1X7GXc2V755O1XKU4dZz7BmFpzFQ=; b=HyxSUxL4s0MPbKNA2zXoUDV+r veeKbBiwt0yi6GoGczL0K9YF7Rf/AtrXLrRwquQ8hyVUaDn9//03f7mfWVeDNo66dQuL/TP+Y4Qwm 1MdbzBQV6vupMk/oCCk6YOZlQmESUePWRHuFjGzEu6eMq3WNH6tAgUs7Wm+U9Fk1TgayM=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gf2le-0005YZ-8R; Thu, 03 Jan 2019 13:10:34 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 3AB6D440080; Thu, 3 Jan 2019 13:10:33 +0000 (GMT) Date: Thu, 3 Jan 2019 13:10:33 +0000 From: Mark Brown To: Yizhuo Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, Bard Liao , Oder Chiou , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , 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. Message-ID: <20190103131033.GU1846@sirena.org.uk> References: <20190103023839.15314-1-yzhai003@ucr.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1YSLKY9nNiKnepPi" Content-Disposition: inline In-Reply-To: <20190103023839.15314-1-yzhai003@ucr.edu> X-Cookie: knowledge, n.: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --1YSLKY9nNiKnepPi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 02, 2019 at 06:38:39PM -0800, Yizhuo wrote: > int ret; > - unsigned int val; > + unsigned int val =3D ~0; > =20 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 =3D regmap_read(rt274->regmap, > RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val); > - if (val !=3D RT274_VENDOR_ID) { > + if (ret || val !=3D 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 =66rom 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. --1YSLKY9nNiKnepPi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlwuCcgACgkQJNaLcl1U h9ATcQf/eBbwaS5qgEtEK51OPB3FNB6vrxxUk5HGFZqdFxZQVgcz3XNeMEDhcccS cKGpg1ksiEpLIog6GK6KmLkHrfiA8aWoHhkuDGxMnogfySqU9qA3V8LbQoBGAh56 x3tnhky9Iuyj+Wcj0WKw00dsBlDxrorF3z9297WkFsopR3J7Sd7OHZjQFYopthin mhAuUkwTfP1QQDANxH3AciBZwA8CJQQ+XqB/ORavzZqWfi8znP9NnN+fdOuHzqWK qbzU2aLsWFiGzfOxFUjyJTWSr0UlgKTE8YpORTWNsSQhYTchJLnwAqStlaFW00VA Dczuw8DOS8aDFgHNENAmUUhiSv0KpQ== =D6U7 -----END PGP SIGNATURE----- --1YSLKY9nNiKnepPi--