Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4562403pja; Thu, 21 Nov 2019 21:55:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzqumxB2slbT+tWnScmnBjL+TKOmHl05JuM2CYd3tN8gIqVbdNp29EleSNC6tbNLPTtv9Za X-Received: by 2002:a17:906:52d3:: with SMTP id w19mr20090879ejn.268.1574402123327; Thu, 21 Nov 2019 21:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402123; cv=none; d=google.com; s=arc-20160816; b=BdrC6jSLLnUESAMQb4onr0uPws8Mr/VIWB1e0SjIWGCvkkwDpzOMo6TvL6fCfg9RK0 8FTAkiviOwWep7WVMS/DALIFOeBcEts+JLx+6svM37ivblXzGCqb1fIN65Zgnr/XCz/5 dn8zjmtdDD5/EtV/TX/yf/wCLOiuj1TTYj7jXqhUUY0djeSrjN3X5rXAlcF28gYzjO3e rVRV+1zt33cCTTtbyu9E6UR4BYmt/RGWNhT/yzD+XSs7nW/9pQnFPE6+k8JSBt8p+reR /KLHv967bNrEa/l4jwE5Odzb0FHaTQdU7GQaNGO8VpmuaYZnADVFsWUtvtyJPdkFJvVV dKYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S844NWRdSqOJ3WPgCnbTGISg/wEMJXXcQvaD1mhNiek=; b=ozlAQK8ratAqouE9tCziYySN47ErSzi5y0yk+7EmUwpLZboYaJIARe6HsHZ60XBPfd +M8mnkASeucy0iETsxq5xLB0WlP5ee6wXe5AaEfuutFD3j6tcrqpe1Jv8NtN5aLJnpN6 nm+AQwebUS++Gly3dLwuyYyv9wbtLeSEJe+zw/+C1w21+oyRvDc6LOguX0Rrax1KHaiT HE2yiyqsVk+I2Yi425NjtScE5oI63yTANHoyGEe4MmqV1kuzEVbL2ohhOzr4ICPskVgp 8GsMqsp3N1t+MGLhWb93I/pqr9IzbIpCdniUD9VaeN4SuweseGANrjVbfLZJ5w2RIkiS RGBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s53GS3P8; 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=pass (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 y16si3636093ejp.400.2019.11.21.21.55.00; Thu, 21 Nov 2019 21:55:23 -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=pass header.i=@kernel.org header.s=default header.b=s53GS3P8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728090AbfKVFvT (ORCPT + 99 others); Fri, 22 Nov 2019 00:51:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:56146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728024AbfKVFvN (ORCPT ); Fri, 22 Nov 2019 00:51:13 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CB8D20726; Fri, 22 Nov 2019 05:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401872; bh=Z+GRDGXvde3IqbQAMR4FdDnPTDNca8lROt2Va9pj+gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s53GS3P8P+SgyGd+4N2jasZm2MwqYgXor6uxxFRuHtrmUFEqclG/bZVYosFy+4JJ9 JnOrasUO8aHqCuoHysa7bgw9x4+JPWDDhleF6+3JcTEejx0UOGQiFTpR8ln5t6Tp7Y nagd/jmqSmGxAtOPFwKOAofqD5oxhSekD35CX1ho= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kangjie Lu , Mark Brown , Sasha Levin , linux-omap@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 108/219] drivers/regulator: fix a missing check of return value Date: Fri, 22 Nov 2019 00:47:20 -0500 Message-Id: <20191122054911.1750-101-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kangjie Lu [ Upstream commit 966e927bf8cc6a44f8b72582a1d6d3ffc73b12ad ] If palmas_smps_read() fails, we should not use the read data in "reg" which may contain random value. The fix inserts a check for the return value of palmas_smps_read(): If it fails, we return the error code upstream and stop using "reg". Signed-off-by: Kangjie Lu Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/palmas-regulator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index bb5ab7d78895b..c2cc392a27d40 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c @@ -443,13 +443,16 @@ static int palmas_ldo_write(struct palmas *palmas, unsigned int reg, static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) { int id = rdev_get_id(dev); + int ret; struct palmas_pmic *pmic = rdev_get_drvdata(dev); struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata; struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id]; unsigned int reg; bool rail_enable = true; - palmas_smps_read(pmic->palmas, rinfo->ctrl_addr, ®); + ret = palmas_smps_read(pmic->palmas, rinfo->ctrl_addr, ®); + if (ret) + return ret; reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; -- 2.20.1