From patchwork Wed Oct 19 11:49:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 78231 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp203960qge; Wed, 19 Oct 2016 04:49:22 -0700 (PDT) X-Received: by 10.99.206.17 with SMTP id y17mr3914715pgf.48.1476877762093; Wed, 19 Oct 2016 04:49:22 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id s77si36815534pgs.207.2016.10.19.04.49.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 04:49:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwpLt-0002Lz-1y; Wed, 19 Oct 2016 11:48:09 +0000 Received: from conuserg-11.nifty.com ([210.131.2.78]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bwpLo-0001tt-Iz for linux-arm-kernel@lists.infradead.org; Wed, 19 Oct 2016 11:48:06 +0000 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id u9JBl9dp032386; Wed, 19 Oct 2016 20:47:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u9JBl9dp032386 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1476877630; bh=YlAJPPXSEYIFgQYl9SqLKSrffZu76xEOFQ+UWQkPYAI=; h=From:To:Cc:Subject:Date:From; b=VRKZqmEegyZ5SHaNqE7zP1fZN8IHUDNriFlvtAzNwZTuAhMLzAc48dzal4i3eL3jb NNddP2wMovLO4N0NnZyZan8k4zsZ2ndhlD8NDLC8cdtBjt1U+cSXchX3hCOOTHOnkN zghB//DPoJTjyxZtMeNU+pDP7TNBVAaj3PV7bKiKmQW1B8cm96Ghbwtkj1e3Sr5ba1 5qicHQHRa/X2M7A9ZLK1NjDKsGuWv9GPWlsyyhte+MT8bKEJKToWpw+PdAasFqQbg2 3DNMu6/1xmOSVc0VjcuGdnoktO6OvrxHssh60zNIq4oSStgRUgLSIeCV/BQcH7mU8G BTAMlBVBjL5ew== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-clk@vger.kernel.org Subject: [PATCH] clk: uniphier: fix memory overrun bug Date: Wed, 19 Oct 2016 20:49:39 +0900 Message-Id: <1476877779-27854-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161019_044805_069204_F9C48587 X-CRM114-Status: UNSURE ( 8.42 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The first loop of this "for" statement writes memory beyond the allocated clk_hw_onecell_data. It should be: for (clk_num--; clk_num >= 0; clk_num--) ... Or more simply: while (--clk_num >= 0) ... Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock driver") Signed-off-by: Masahiro Yamada --- drivers/clk/uniphier/clk-uniphier-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/clk/uniphier/clk-uniphier-core.c b/drivers/clk/uniphier/clk-uniphier-core.c index f4e0f6b..84bc465 100644 --- a/drivers/clk/uniphier/clk-uniphier-core.c +++ b/drivers/clk/uniphier/clk-uniphier-core.c @@ -79,7 +79,7 @@ static int uniphier_clk_probe(struct platform_device *pdev) hw_data->num = clk_num; /* avoid returning NULL for unused idx */ - for (; clk_num >= 0; clk_num--) + while (--clk_num >= 0) hw_data->hws[clk_num] = ERR_PTR(-EINVAL); for (p = data; p->name; p++) {