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: 9384857 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B27ED60762 for ; Wed, 19 Oct 2016 16:35:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A543328694 for ; Wed, 19 Oct 2016 16:35:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99BE228F7C; Wed, 19 Oct 2016 16:35:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28931290F9 for ; Wed, 19 Oct 2016 16:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753103AbcJSQfG (ORCPT ); Wed, 19 Oct 2016 12:35:06 -0400 Received: from condef006-v.nifty.com ([210.131.4.243]:34617 "EHLO condef006-v.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752940AbcJSOKi (ORCPT ); Wed, 19 Oct 2016 10:10:38 -0400 Received: from conuserg-11.nifty.com ([10.26.8.74])by condef006-v.nifty.com with ESMTP id u9JBmAcf012773; Wed, 19 Oct 2016 20:48:10 +0900 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 Cc: Masahiro Yamada , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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++) {