Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3315790imu; Sun, 11 Nov 2018 12:12:19 -0800 (PST) X-Google-Smtp-Source: AJdET5eqbKikCqu6YQ5S/MNTnCw1Gtx9ZFFDM/lH4VFVkVng1J/o0kgz8UtFGHB9YFJNLt68362s X-Received: by 2002:a62:cc4:: with SMTP id 65-v6mr17302503pfm.127.1541967139667; Sun, 11 Nov 2018 12:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541967139; cv=none; d=google.com; s=arc-20160816; b=q++U+Vb3udtOyrU+7nyQGNdKvxfpgo7FeNMhvTw89+/W4ZaXSBZAZESESKYcM6dvcN hJUgnRLuZ0swk8DdJeJUay91KeEWM/2VGDqNcla7Zm5BVAFTlWzP59NFuOYeqoG1NzUk gO4LeV7XgLMdRr5oPnVt6pxag99hyTq0O/a9o0bmYRqps5RbshbXaAbzZjzSSt0L7an0 F5JvH3H8XzxKz4G6u6NmEtZRnmye45udMYXaQTFpVwrrUy76dAvjsFWDChar127eM7gJ JXjyJnqkQYZvFiYiGurBHcHTTqOU/8yFuGuxdyyf0qOteH01/Olo7YBbCbslLv0xgu6n BeAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=euhK225raXBMVK8WGDgLqMfkxXtOX5XTDOBZIG3ZZgs=; b=jlJY4ceDkrNVrV75VeMpDQwjLJoXEPDVzISmNWPxc1clZFSrglSO7FMQ+H2ZmkQvV0 KiGQfk2Dgi+T5a37T529DaLr8cxZK9VzZ7FqQXQTOfuRFausu3wBvUPWi1x+mZsCNqCT jvWzKCslXYWMG8392ba1xMfGioG44BVUHenPdXdtsJbRakLJVPJKWpRtR60cquRg2mFY 0CfYaojUdjmYY/04Zv7sVvaDrpIEvSMTTpu92rQYs7u6P5HJQhqhlygqaJbwevMVezOU 0i/6tuvJQGEKsqedvsh0+86nZt4p0CorHlLlFIPSe/4tFMHCrnpmsiY1MNkQNJuJnEBh Of2A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p82-v6si16232396pfi.12.2018.11.11.12.12.04; Sun, 11 Nov 2018 12:12:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731671AbeKLGAs (ORCPT + 99 others); Mon, 12 Nov 2018 01:00:48 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52468 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730968AbeKLGAr (ORCPT ); Mon, 12 Nov 2018 01:00:47 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtB-0000oN-P3; Sun, 11 Nov 2018 19:59:21 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001Pu-SA; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Evgeniy Polyakov" , "Stefan Potyra" , "Greg Kroah-Hartman" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 048/366] w1: mxc_w1: Enable clock before calling clk_get_rate() on it In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Potyra commit 955bc61328dc0a297fb3baccd84e9d3aee501ed8 upstream. According to the API, you may only call clk_get_rate() after actually enabling it. Found by Linux Driver Verification project (linuxtesting.org). Fixes: a5fd9139f74c ("w1: add 1-wire master driver for i.MX27 / i.MX31") Signed-off-by: Stefan Potyra Acked-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- drivers/w1/masters/mxc_w1.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) --- a/drivers/w1/masters/mxc_w1.c +++ b/drivers/w1/masters/mxc_w1.c @@ -111,6 +111,10 @@ static int mxc_w1_probe(struct platform_ if (IS_ERR(mdev->clk)) return PTR_ERR(mdev->clk); + err = clk_prepare_enable(mdev->clk); + if (err) + return err; + clkrate = clk_get_rate(mdev->clk); if (clkrate < 10000000) dev_warn(&pdev->dev, @@ -124,12 +128,10 @@ static int mxc_w1_probe(struct platform_ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); mdev->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(mdev->regs)) - return PTR_ERR(mdev->regs); - - err = clk_prepare_enable(mdev->clk); - if (err) - return err; + if (IS_ERR(mdev->regs)) { + err = PTR_ERR(mdev->regs); + goto out_disable_clk; + } writeb(clkdiv - 1, mdev->regs + MXC_W1_TIME_DIVIDER); @@ -141,8 +143,12 @@ static int mxc_w1_probe(struct platform_ err = w1_add_master_device(&mdev->bus_master); if (err) - clk_disable_unprepare(mdev->clk); + goto out_disable_clk; + + return 0; +out_disable_clk: + clk_disable_unprepare(mdev->clk); return err; }