Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1688180ybi; Wed, 17 Jul 2019 20:09:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCvWz1J73Qu0vhlUqR+Ol4d1RPx43e5e+OoQ+whwcgaIC7Kjl/h60cBxrGx34uDMzIimbt X-Received: by 2002:a63:fb43:: with SMTP id w3mr11744240pgj.403.1563419365021; Wed, 17 Jul 2019 20:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419365; cv=none; d=google.com; s=arc-20160816; b=Yu2Re+PZYsEFHG3dbU1MaYsnaUxi516GM3P0nirtzmf4/04Pb+XNpJneGRJBnpHBmw W867Jepora1WV8ZJkJcgsSaP2zt9n0yN2ZJnliGEMl+hJSTmAM6GXCQiWOSeDq3J3gqQ E3Dr8BOYT8PE2LkEKkPD9QpNZLlaUSpiPrdybXiPGYtJq4iyWzFi/6y0HyuaXXvXy90L xOjDkTcWezueJAbb6LvrSezxtq9KSKWhJaqbGSOIZTjVH42tf4wY7mlipNGYmlF/Zw7p 8MeVQpBa0gfdBGPMlOJBSwt3S1CRDjWbZ3wv31Obn8YWUf1Xf300hXVqC7YCe1Z2ScW6 H1Tg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T0835rckFmyGY3yPJCUv+JHAH18PIEns8W83MRaOVv4=; b=UhIB8WW6xpHzzdKSUqTezpR9HnlX6QKE+CoC3CVZVgkDyb6afdr5ETjRnHv3eZhtfh Ujfws1ma/P3g05qwevltzIl7G7Ivkj02z2NJQ9Z7UYEi0K39wo93tG99eI7qN2BcUmqY nZLE712aEev/6/nAXn0AgN6KQV5JWXjMvtJ1l83ROzrWXQQDl8S9bRBtqvvXrKuNeH/s 9kgg5eL6u0beNr8vrwSNjqz/OP6/0KcxPNNwyIkRCSg4DnFs6t3W4o/mIiUsbsoi7RFR P6PHdQjiKZO9o4p3SqjnS9k/gXYp+j6PCkiNMTTW26S324wXUJgxZJ+o0Bftzz9Fqq+l Fe8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uax39zxJ; 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 a13si838028pgw.81.2019.07.17.20.09.09; Wed, 17 Jul 2019 20:09:25 -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=pass header.i=@kernel.org header.s=default header.b=uax39zxJ; 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 S1728103AbfGRDGu (ORCPT + 99 others); Wed, 17 Jul 2019 23:06:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389786AbfGRDGs (ORCPT ); Wed, 17 Jul 2019 23:06:48 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5534D2173B; Thu, 18 Jul 2019 03:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419207; bh=wqOGoStqOkwffvrYO84oIEN88EJVB13j9jeIKwL9hdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uax39zxJVF2n5N6535nhRrAE9VRW41CdCNgPVoHl3+lOXWMcR4eBGca1rRDJvLyJW TPChnqp297gu+InC0CU4Y/+uw+eW4Apt5+UKJkTsgseWBKp9SOEOZ/00Hk+xiIGfRh QvO16agUBA/m+2z3dgVrNE6bM9a4afJ/GCw0RrTI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomi Valkeinen , Tony Lindgren , Peter Ujfalusi , Stephen Boyd , Sasha Levin Subject: [PATCH 4.19 08/47] clk: ti: clkctrl: Fix returning uninitialized data Date: Thu, 18 Jul 2019 12:01:22 +0900 Message-Id: <20190718030049.197902316@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 41b3588dba6ef4b7995735a97e47ff0aeea6c276 ] If we do a clk_get() for a clock that does not exists, we have _ti_omap4_clkctrl_xlate() return uninitialized data if no match is found. This can be seen in some cases with SLAB_DEBUG enabled: Unable to handle kernel paging request at virtual address 5a5a5a5a ... clk_hw_create_clk.part.33 sysc_notifier_call notifier_call_chain blocking_notifier_call_chain device_add Let's fix this by setting a found flag only when we find a match. Reported-by: Tomi Valkeinen Fixes: 88a172526c32 ("clk: ti: add support for clkctrl clocks") Signed-off-by: Tony Lindgren Tested-by: Peter Ujfalusi Tested-by: Tomi Valkeinen Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/ti/clkctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c index ca3218337fd7..dfaa5aad0692 100644 --- a/drivers/clk/ti/clkctrl.c +++ b/drivers/clk/ti/clkctrl.c @@ -229,6 +229,7 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec, { struct omap_clkctrl_provider *provider = data; struct omap_clkctrl_clk *entry; + bool found = false; if (clkspec->args_count != 2) return ERR_PTR(-EINVAL); @@ -238,11 +239,13 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec, list_for_each_entry(entry, &provider->clocks, node) { if (entry->reg_offset == clkspec->args[0] && - entry->bit_offset == clkspec->args[1]) + entry->bit_offset == clkspec->args[1]) { + found = true; break; + } } - if (!entry) + if (!found) return ERR_PTR(-EINVAL); return entry->clk; -- 2.20.1