Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp993128ybn; Wed, 2 Oct 2019 09:15:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxANvC1HmY7SFir9ptVcZiqZ3McAa/pHRiotPbHBU3pTiqpOoMhNKCfPiad4zgG5rSUwwy+ X-Received: by 2002:aa7:c306:: with SMTP id l6mr4729628edq.78.1570032908983; Wed, 02 Oct 2019 09:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570032908; cv=none; d=google.com; s=arc-20160816; b=oKB8xSqXOQKqT5TOFstCwP0xIi0b0O6Gd8QMfcWfkK/Zfs3Q3A8Sn2Y127/yhjCqNZ 6ljLifp2vMosXZdlsO8KdNa9hJdimG4YoHt98h5SV56BPUtjfuEhgVTfvgATuY8XPQ1F cS6nXAr3M1yqHqotM4EjRrfpa68Hp0fgQYO1EFGzgPw0xAtUtStUN/iTwnqg5I4LzYRH KU+hcQIcDrMW2R/YGu5x/FXTMWUHz+D7Ab2/nf7v/+18X1Q/uhQA5/+/sXoYxlKl4mAu 30Jfom7XOJthVmskiKYxuMA71/q0v2WINutxnFQ4PLSvMlNv49pzYg2yMFQTX0DBVIO7 GVng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :ironport-phdr:ironport-sdr:dkim-signature; bh=N3wwXKf0R7CCR4EOyO31YNISlkUagx3YW+ubBEkjy90=; b=GHL5nHRR3emeV/lH2Ckwn/k0dHe46o4pnHgmv/bZAVrf3qd+ni/xmBeGP55a45ekkA asTiI1Qx2UBMdXANkVD5z3sx6C0f0GhfLB+d96rckHRHGmZcPikNzraEIGO+SBN9cyJk wY6LQfD9avybqTbk0YTcr7vDIQN4VDovcwmNNf1DOVaRq0aR2xljCRLcH+lyRgQS2lgb 2dY1F1MTIrDtEfORaMRflP9kU+bK36DousZOf5IHx3XYi2Zo8O2SS6DRE20MTqXHGFDC Ef0NEA2aMn8+P/mLUeSeGhvhNWnPW4gHBgoPDOOrG3KkgMwEvhM/l0+zOr0QSFmHC8cW XcdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ucr.edu header.s=selector3 header.b=DXQLRpM4; 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=ucr.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si11076598ejc.399.2019.10.02.09.14.43; Wed, 02 Oct 2019 09:15:08 -0700 (PDT) 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=@ucr.edu header.s=selector3 header.b=DXQLRpM4; 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=ucr.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728864AbfJBPn0 (ORCPT + 99 others); Wed, 2 Oct 2019 11:43:26 -0400 Received: from mx5.ucr.edu ([138.23.62.67]:45382 "EHLO mx5.ucr.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725875AbfJBPnZ (ORCPT ); Wed, 2 Oct 2019 11:43:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ucr.edu; i=@ucr.edu; q=dns/txt; s=selector3; t=1570031004; x=1601567004; h=from:to:cc:subject:date:message-id; bh=Z+EVLw9fpQeyY0pHsne85bY8IJwYorDnDkYoPc67XmY=; b=DXQLRpM46eCMUjZ+Ah7QdtmlYmyjdNkFKiciIWOfrgYzJiYzZ9IeIMtI 21IRbYBS91JAt0GdQeg3TGH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VL+d1cqfEcd8HWW?= =?us-ascii?q?ZNQsNdWipEAoO9dIsPFOsBPeBXr4LguVUAtAa1BQetBOzxzj9Hm2L90ak03u?= =?us-ascii?q?g9FA3L2hErEdATv3TOtNj7NLkcX/27wqfLyjvOdO9a1Svn5YTUaB0tve2AUL?= =?us-ascii?q?RtesTR00kvEAbFg02SpozkPjKV1vkNs2+G5OdnVeOuim4npBtwojSz2sshhJ?= =?us-ascii?q?LEhp8JxVDe7yl23ps6JcChRUN9fNWqE4NQujmEO4dqRs4uWWJltSYgxrEYpJ?= =?us-ascii?q?K2fDIGxIkjyhPdc/CLbomF7xb5WOqPLzp1hGhpdKy+ihqo80WtxevxXdSu3l?= =?us-ascii?q?lQtCpKiNzMu2gI1xzU98eIVONw/lyk2TaTzwDT7fxEIVwsmarbNZEhxrkwm4?= =?us-ascii?q?IWsUvZHy/2nFz6jLeZdkk54+So5fnrb7Hkq5OGOI90jQb+MqsqmsOhG+g3Lg?= =?us-ascii?q?8OX22D9eS90r3s41H5Ta1UgvEqlqTVqpPXKMQBqqKnHgNY0pwv5wu7AjqkyN?= =?us-ascii?q?gYmGMILFNBeBKJlYjpPFTOLej4DPa+g1SjijZry+zaMrDvGZjNM2TMkK37cb?= =?us-ascii?q?lj9kFc1RI/zcpD6JJMFrEBPPXzV1f1tNzZCB85LgO1z//kCNpjzIMeX3yAAq?= =?us-ascii?q?uCPaPMvl+H+PgvL/OPZIALojb9LeYq5/r0gX8+g18dcvrh84EQbSWJH+ZmPk?= =?us-ascii?q?LRNWv+gt4AST9Rlhc1VqrnhEDUAm0bXGq7Q69pvmJzM4mhF4qWA9/1jQ=3D?= =?us-ascii?q?=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2FAAADYxJRdh8XXVdFmHQEBBQEMBQG?= =?us-ascii?q?BVAcBCwGDXUwQjSCGKQaLPnGFeoMLhSeBewEIAQEBDAEBLQIBAYRAgkAjNQg?= =?us-ascii?q?OAgMJAQEFAQEBAQEFBAEBAhABAQEIDQkIKYVAgjopgzULFmdWPwEFATUiOYJ?= =?us-ascii?q?HAYF2FAWjfYEDPIxYiGcBCQ2BSAkBCIEiAYc0hFmBEIEHhGGEKIM9gkQEgTc?= =?us-ascii?q?BAQGVI5ZNAQYCghAUgXiTEieEOok9i0EBLYwNmxgCCgcGDyOBMQOCDU0lgWw?= =?us-ascii?q?KgURQEBSBWw4JFY4uITOBCJA8AQ?= X-IPAS-Result: =?us-ascii?q?A2FAAADYxJRdh8XXVdFmHQEBBQEMBQGBVAcBCwGDXUwQj?= =?us-ascii?q?SCGKQaLPnGFeoMLhSeBewEIAQEBDAEBLQIBAYRAgkAjNQgOAgMJAQEFAQEBA?= =?us-ascii?q?QEFBAEBAhABAQEIDQkIKYVAgjopgzULFmdWPwEFATUiOYJHAYF2FAWjfYEDP?= =?us-ascii?q?IxYiGcBCQ2BSAkBCIEiAYc0hFmBEIEHhGGEKIM9gkQEgTcBAQGVI5ZNAQYCg?= =?us-ascii?q?hAUgXiTEieEOok9i0EBLYwNmxgCCgcGDyOBMQOCDU0lgWwKgURQEBSBWw4JF?= =?us-ascii?q?Y4uITOBCJA8AQ?= X-IronPort-AV: E=Sophos;i="5.67,574,1566889200"; d="scan'208";a="80107053" Received: from mail-pg1-f197.google.com ([209.85.215.197]) by smtpmx5.ucr.edu with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Oct 2019 08:43:21 -0700 Received: by mail-pg1-f197.google.com with SMTP id x31so13622639pgl.12 for ; Wed, 02 Oct 2019 08:43:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N3wwXKf0R7CCR4EOyO31YNISlkUagx3YW+ubBEkjy90=; b=ZsXlrAVrecOeRH+/0yXMF4NA6IiyGRRXzS1zAmfqNTt192wQwre7FAF6takhZDWPuq XCPaV07mxgNlQZUpkohPzesyXfmFYKCZTp+moqIhs7BPp7R9wF11cOJzSW/YdXvXHOkB skifL+NM0AfiF8hwqn+4EqN1xnt/6S4JKZg3kA4MheJ9gLPTaN/J0UJpsUfi8XHGgXZT 97zzEepuygFpGwU5Q4kNH8ttt0lQKmpBpwpw3pztCjHygzdhHhto0EDEwcBLgwZrE9bI SSeGZsnagBIQomfaweNg8D85svrOvD2ZReu8/DTG9X9K0tnZiDKzbbsz9VxdXj+3Huc+ mmtg== X-Gm-Message-State: APjAAAUKeg2EQ5Fd0ZiJh4iA41tXD+kNlJnOMVPAPppWbBR/h7PTqpo/ icM2DXglgG8yCNdHegf09NGFmYiJxzgfzPSaaxgQYPjpQAZOPr+yOAehhi8UvBvh6f4Wg7IRR28 v7UPtGhJUGmnYyYBZ7ilsnf0oYQ== X-Received: by 2002:a17:90a:7181:: with SMTP id i1mr287703pjk.39.1570031001253; Wed, 02 Oct 2019 08:43:21 -0700 (PDT) X-Received: by 2002:a17:90a:7181:: with SMTP id i1mr287657pjk.39.1570031000821; Wed, 02 Oct 2019 08:43:20 -0700 (PDT) Received: from Yizhuo.cs.ucr.edu (yizhuo.cs.ucr.edu. [169.235.26.74]) by smtp.googlemail.com with ESMTPSA id a23sm13678588pgd.83.2019.10.02.08.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 08:43:20 -0700 (PDT) From: Yizhuo Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, Yizhuo , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: max17042_battery: fix the potential uninitialized use in max17042_write_verify_reg() Date: Wed, 2 Oct 2019 08:44:06 -0700 Message-Id: <20191002154406.8875-1-yzhai003@ucr.edu> X-Mailer: git-send-email 2.17.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In function max17042_write_verify_reg(), variable "read_value" could be uninitialized if regmap_read() fails. However, "read_value" is used to decide the control flow later in the if statement, which is potentially unsafe. Signed-off-by: Yizhuo --- drivers/power/supply/max17042_battery.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 0dfad2cf13fe..e6a2dacaa730 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -486,12 +486,15 @@ static void max17042_external_power_changed(struct power_supply *psy) static int max17042_write_verify_reg(struct regmap *map, u8 reg, u32 value) { int retries = 8; - int ret; + int ret, err; u32 read_value; do { ret = regmap_write(map, reg, value); - regmap_read(map, reg, &read_value); + err = regmap_read(map, reg, &read_value); + if (err) + return err; + if (read_value != value) { ret = -EIO; retries--; -- 2.17.1