Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6357678ybp; Tue, 15 Oct 2019 13:44:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAOIu8dgnpx764hJIzyx8mjX461RfZmKZnyD5x/pUjR8FZSQSXJ+hbuAWBHDw8Aa0/htQ2 X-Received: by 2002:a50:fb84:: with SMTP id e4mr35544556edq.181.1571172275579; Tue, 15 Oct 2019 13:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571172275; cv=none; d=google.com; s=arc-20160816; b=sq0vVtr0cnW23hpPJHzMTPAsQSJC50GG+NQ2NBe5dTCWeWbjPz7dnxSR/yaJuB+xNf YtBEHJmxV0zYz4y/EDSBGQmEdn6A8xrGHGItCMk9r8tWMNaIqyeY2xlchuGA+oBXf0L4 ZAGAxeKO3UoctXrPbNyLieGh/fRzEtoqSBywl6WndKQwkcMHWkh3r0O9fP1QAGLF73GX 9zUJgNXrKJtQWsZU7WoGWw1MAGWc3deCaZ36dDAie+znG8xzPaRIVRbUb/c/imndFBWC gsf+qiMy4KFGP6t9Qf9Lg+uT7TlyKKQOfvfVjZwsHuJPJ0ogNhy1iXMG0mG2N3tUNhvm nmLw== 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=Oyyo8ueGcSv2C2YN7t5+4dy6tp5fxBoXld6XJLZPnpM=; b=K5c5tB/Ntp2TDQ198Fi9PTVtyQWcG2Od/RijjVieq2ZWD4DcEkzQSfzPLTMSxfM/w4 vhEBAva/SGT+jUeKLQgwxYbH52/oxQPTzIHh7GacF33sINLcYJXmdNG0eRJrLyfby40/ 5TDnjruuzAt4/wuaLPAshGBWnRxz+KyhIEdTbM+RiLshWcR7S8rHc6vVIAxJhZOcLbfA 0LbLQcVJZLanqqwsKbr2lbGOcuwu01y76Ql9fdp3VdJl+CeGlzv0yqg+kQ0XjL+8HE/z y/Z5rxumMZPULsUB6axhgb8A30Qpy1la1VabHH49pesi3ueLxY/UXF+mjF1zmW/bfgGy 29EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ucr.edu header.s=selector3 header.b=VbW6x0M0; 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 d1si14392940eds.148.2019.10.15.13.44.11; Tue, 15 Oct 2019 13:44:35 -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=VbW6x0M0; 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 S1728714AbfJOQ51 (ORCPT + 99 others); Tue, 15 Oct 2019 12:57:27 -0400 Received: from mx6.ucr.edu ([138.23.62.71]:26748 "EHLO mx6.ucr.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfJOQ51 (ORCPT ); Tue, 15 Oct 2019 12:57:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ucr.edu; i=@ucr.edu; q=dns/txt; s=selector3; t=1571158647; x=1602694647; h=from:to:cc:subject:date:message-id; bh=tJT8udUe23SQ/yMvXD9JrhV+zdyow2x8Zk5qa/cM1lw=; b=VbW6x0M03Cs7mOz+EU+pUDdXKpVXDoNksCoRPuxMbWvQRIgADkWkq55D dB78/yUOMwykvpvgaYC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= =?us-ascii?q?9HU8ZUVixBGZi8b4oJD+oOIO1WsZDzrEYArRu/GwasAP7gwSJMinL4waE21u?= =?us-ascii?q?IsGhzE0gM9BdIDqHTaosvoOqkcUu67y7LFwSnfY/5MxTvw8pTEfgwnrPqRXb?= =?us-ascii?q?xwa83RyUw3GgzHj1WRqIzlPy6S1u8QtGWa7+thVeK1hG4mtw19vjaiy9wxio?= =?us-ascii?q?bVnIIZ0E7L+jhkwIssI9CzVU11Yca8HZdOqy2XM5F6T8AiTm1ypio216EKtY?= =?us-ascii?q?SlcCQW1Jgr3wPTZv2DfoSS/B7uWuacLS1miH9kYr6yhRm//E69wePmTMa0yk?= =?us-ascii?q?xFri9dn9nJsXACygLc59CcSvt44kehwTGP1x3P6u1cIUA7i67bK5k5z741jJ?= =?us-ascii?q?UTsEDDEjbumEX4kaOab0sk9va05+j7eLnmqZicN4h7igH6LKsigNCwAeM9Mg?= =?us-ascii?q?QWXmib//qz1KH78EHnXLlHiuc6n6rZvZzAO8gXu7K1DxVL3oo/9xqzFzKm38?= =?us-ascii?q?4ZnXkDIlJFYhWHj43xNlDOIfH4De2wg1WwnDt3yf3LJaDhDYnXLnTZjrjuYK?= =?us-ascii?q?t951ZGyAUv1dBf+45UCrYZLfL3W0/xssHYDxAgPwy33ennEtN92Z0aWW+UHK?= =?us-ascii?q?+ZP73dsUWS6uIsPeaMfokVtyj5K/Q/4P7ul3A5yhczZ66siKoWenClGbwyMl?= =?us-ascii?q?eZaHu02owpDGwQ+AcyUbq52xW5TTdPaiPqDOoH7TYhBdfjUt/O?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2EvEgAd+qVdgMjSVdFmHgELHIFwC4N?= =?us-ascii?q?gTBCNJ4YzBospGHGFe4owAQgBAQEMAQEtAgEBhECCcSQ3Bg4CAwkBAQUBAQE?= =?us-ascii?q?BAQUEAQECEAEBCQ0JCCeFQoI6KYM1CxYVUoEVAQUBNSI5gkcBglIlBaIKgQM?= =?us-ascii?q?8jCUziGMBCQ2BSAkBCIEihzWEWYEQgQeDbgdshAMKG4M+gkoEgTkBAQGLQYl?= =?us-ascii?q?ycJVrAQYCghAUgXqTFSeCOoICiUA5iwwBLYwYmycCCgcGDyOBRYF8TSWBbAq?= =?us-ascii?q?BRFAQFIIHji4hM4EIjXuCVAE?= X-IPAS-Result: =?us-ascii?q?A2EvEgAd+qVdgMjSVdFmHgELHIFwC4NgTBCNJ4YzBospG?= =?us-ascii?q?HGFe4owAQgBAQEMAQEtAgEBhECCcSQ3Bg4CAwkBAQUBAQEBAQUEAQECEAEBC?= =?us-ascii?q?Q0JCCeFQoI6KYM1CxYVUoEVAQUBNSI5gkcBglIlBaIKgQM8jCUziGMBCQ2BS?= =?us-ascii?q?AkBCIEihzWEWYEQgQeDbgdshAMKG4M+gkoEgTkBAQGLQYlycJVrAQYCghAUg?= =?us-ascii?q?XqTFSeCOoICiUA5iwwBLYwYmycCCgcGDyOBRYF8TSWBbAqBRFAQFIIHji4hM?= =?us-ascii?q?4EIjXuCVAE?= X-IronPort-AV: E=Sophos;i="5.67,300,1566889200"; d="scan'208";a="82381423" Received: from mail-pf1-f200.google.com ([209.85.210.200]) by smtpmx6.ucr.edu with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 15 Oct 2019 09:57:01 -0700 Received: by mail-pf1-f200.google.com with SMTP id z4so16415289pfn.0 for ; Tue, 15 Oct 2019 09:57:01 -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=Oyyo8ueGcSv2C2YN7t5+4dy6tp5fxBoXld6XJLZPnpM=; b=fv9LbXnOpFWeOZlQ8yMk2r0N0a2/u3fSTFEY9kmLZB4hsJsYMrEpjKCmh4w4skBNaB x10XITlcwOKXSYxr1Cw3mWBg+UIkDZm6CQx1TAo/swNoo/LC3kAgyLFk9Izpa5EVz8td GlYe8uXTMPXYmy0kuStTLsbSujP+D9URxsAFOIGcFfwaQGOZ9kWhhmlLKjz7nnBQjhBx slCuvqbwxbKspHFWPY/ByXHNJ8WoKYQWmATOSWQj2Q8N/RiPQiN6+UPAhwV67vsLxKM/ dPfxoiyA0WTqVedr1jZnCzO6nvT6yl+dj2R31xwkzS3N3CfL/DhNsxNehHjbv3nGZgCs ofLA== X-Gm-Message-State: APjAAAXjBSyI7SNQwVH1cjWbzNLTQbSRc9sVai2L8MxHRgA71M+Qcb5z N5CM5BOBJE9H6lJnR7g/wz0I5By2AXiW1C83jvbz6cW+FAhOagHffpOK5p7pkl0zTXcKJeAGrwT Ov3nX4T1avFmlJ2WnUj3O2XhIkg== X-Received: by 2002:a17:902:9008:: with SMTP id a8mr37063837plp.218.1571158620567; Tue, 15 Oct 2019 09:57:00 -0700 (PDT) X-Received: by 2002:a17:902:9008:: with SMTP id a8mr37063822plp.218.1571158620267; Tue, 15 Oct 2019 09:57:00 -0700 (PDT) Received: from Yizhuo.cs.ucr.edu (yizhuo.cs.ucr.edu. [169.235.26.74]) by smtp.googlemail.com with ESMTPSA id v19sm21864641pff.46.2019.10.15.09.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 09:56:59 -0700 (PDT) From: Yizhuo Cc: zhiyunq@cs.ucr.edu, csong@cs.ucr.edu, Yizhuo , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: rt5033_battery: Fix the usage of potential uninitialized variable Date: Tue, 15 Oct 2019 09:57:37 -0700 Message-Id: <20191015165737.658-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 rt5033_battery_get_present(), variable "val" could be uninitialized if regmap_read() returns -EINVAL. However, "val" is used to decide the return value, which is potentially unsafe. Signed-off-by: Yizhuo --- drivers/power/supply/rt5033_battery.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c index d8667a9fc49b..6a617531698c 100644 --- a/drivers/power/supply/rt5033_battery.c +++ b/drivers/power/supply/rt5033_battery.c @@ -26,8 +26,14 @@ static int rt5033_battery_get_present(struct i2c_client *client) { struct rt5033_battery *battery = i2c_get_clientdata(client); u32 val; + int ret; - regmap_read(battery->regmap, RT5033_FUEL_REG_CONFIG_L, &val); + ret = regmap_read(battery->regmap, RT5033_FUEL_REG_CONFIG_L, &val); + if (ret) { + dev_err(&client->dev, + "Failed to read RT5033_FUEL_REG_CONFIG_L.\n"); + return false; + } return (val & RT5033_FUEL_BAT_PRESENT) ? true : false; } -- 2.17.1