Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp197440imj; Thu, 14 Feb 2019 18:29:03 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0jMpuD+x6LT38qBNtoSs3hPb5u1LDtSfMGjG9uqkjc6JPnTFfyr8+XY/hzJckA3bpZEWL X-Received: by 2002:a63:fa06:: with SMTP id y6mr3080330pgh.177.1550197743171; Thu, 14 Feb 2019 18:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197743; cv=none; d=google.com; s=arc-20160816; b=DYzSXPUa5BX2vNh9xsrKaydqm/zZIPWnApy/KbzuZUWD0QZxMSlx2j6hugekUMWLiQ T1zIhv2o0Cc91BIgRusl0rZGx+smq/EA7EMK816vWm0G/u0V1zh0mIxhQs0RzNW/G9WN FxdUQj2B1wnPJbiZax90Ve/M9jxTvMs7RudoFvDbh/OpAnWlPp50Ziy5cbzTVFOn7Wxj CXqxFIi14+uqnvaIVM03OmXBj2tcDT/F4Z2r7PVIn7i2JcwBmEEdr+y6AyUg5coWmTNq ikfnHC2JAsAv4hzKji4K5bSpUE9BMmdGyKvT9oEgag37sN4UfVyuQEWUk9EK4y1ISB4c BpGw== 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=i632wbzqYykETyUPZNWobN/kTfKuhGG8xaMe+IhkYWQ=; b=ldV+OnlT9KCppgQH+kh+Bv2F+5oDAWFVigsLoWVo3OnMdJxgeShC1xOlDOXcRLulLp JoC3N8wth59P3/QHfAl89xKvsq2k0ynmQUiryDf/oaudjoSA0Ztx/JLppRqOm49gPcWY ZEY2GihyCxDXtnLhqNuShLI94FxpSfBLrCcx+gHMNG0B8DgogzupF+1xaRex4D8KvkAf rdL5RiuA15OtQkoFK4xBBtgV8yyxdgNHzniOAwMuCXYTo3XOEh8uYPiRkS+8O8Jn1Via fFB5XFKbrBXly1gBf0SUu+8dCgBbc+MlvldEebgBoMjo7Q4YjxN5E8LQR6Cj0PXkDNhT GjYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a23cWfYG; 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 l1si4006075pgm.67.2019.02.14.18.28.47; Thu, 14 Feb 2019 18:29:03 -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=a23cWfYG; 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 S1731633AbfBOCJO (ORCPT + 99 others); Thu, 14 Feb 2019 21:09:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:49366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731535AbfBOCJK (ORCPT ); Thu, 14 Feb 2019 21:09:10 -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 788D9222D0; Fri, 15 Feb 2019 02:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196549; bh=UNbvbqI1P3qiTB9wUTijxN9B9QGB4i1nhcneVl2DA5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a23cWfYGRUczzqhidRrixsauxnZK303QKDha7tgaU+wGz4ZCfrsgnQ7Y+Nh+I+xK9 nOV8M+YH4aVp8MNkPZXG+D34UIYYIcHMbSfDUs8otoB9wHnA5skEcUNkkYfEMWGQPm 54CxFLcfi9LOcfs3aVhRRehiXoEvSzZoWPaSSZjk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marek Vasut , Marek Vasut , Alexey Firago , Laurent Pinchart , Stephen Boyd , linux-renesas-soc@vger.kernel.org, Sasha Levin , linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 09/77] clk: vc5: Abort clock configuration without upstream clock Date: Thu, 14 Feb 2019 21:07:47 -0500 Message-Id: <20190215020855.176727-9-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 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: Marek Vasut [ Upstream commit 2137a109a5e39c2bdccfffe65230ed3fadbaac0e ] In case the upstream clock are not set, which can happen in case the VC5 has no valid upstream clock, the $src variable is used uninited by regmap_update_bits(). Check for this condition and return -EINVAL in such case. Note that in case the VC5 has no valid upstream clock, the VC5 can not operate correctly. That is a hardware property of the VC5. The internal oscilator present in some VC5 models is also considered upstream clock. Signed-off-by: Marek Vasut Cc: Alexey Firago Cc: Laurent Pinchart Cc: Stephen Boyd Cc: linux-renesas-soc@vger.kernel.org [sboyd@kernel.org: Added comment about probe preventing this from happening in the first place] Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk-versaclock5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index decffb3826ec..a738af893532 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -262,8 +262,10 @@ static int vc5_mux_set_parent(struct clk_hw *hw, u8 index) if (vc5->clk_mux_ins == VC5_MUX_IN_XIN) src = VC5_PRIM_SRC_SHDN_EN_XTAL; - if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN) + else if (vc5->clk_mux_ins == VC5_MUX_IN_CLKIN) src = VC5_PRIM_SRC_SHDN_EN_CLKIN; + else /* Invalid; should have been caught by vc5_probe() */ + return -EINVAL; } return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src); -- 2.19.1