From patchwork Thu Aug 30 17:34:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10582419 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB571180E for ; Thu, 30 Aug 2018 17:36:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D85122C310 for ; Thu, 30 Aug 2018 17:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC76F2C2E5; Thu, 30 Aug 2018 17:36:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 5BC7C2C310 for ; Thu, 30 Aug 2018 17:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeH3Vj3 (ORCPT ); Thu, 30 Aug 2018 17:39:29 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39461 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727173AbeH3Vj3 (ORCPT ); Thu, 30 Aug 2018 17:39:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id g20-v6so4201988pgv.6 for ; Thu, 30 Aug 2018 10:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XcJSe78V8boHm9GZNkvLbiaAQhjcHuNbYLHww8/UvTE=; b=jGQ2PLB4Oc8wKUevs17KJyWm5G3B/BRnnkj4aO4WKsjdQ5RB3WcttL1DdPVb4bp1sV ystCCfTcIv5WpSjvww2pKr6a8xliJlY5uv4GFJJ9DirZ8o/ZtMXYucB0E1rg724woiJG LkCsK3K0PsGTkt+gDJyMxshn9K8m/yDtqc4KY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XcJSe78V8boHm9GZNkvLbiaAQhjcHuNbYLHww8/UvTE=; b=MBVdi3MN7adJ1tnT3xOv+Q4Uw+S91KMUvlsSfm7RoUUcSKjFb/Txab3vMqVgrG1yKJ F0x62JETvIOyqi6eMdRR79Zp1nTagZhfY9qPFsvKQ1LeH4pNtbuoW2RaQUehVwcPh9bc gFsVa+eJ09taPcceTO9DoRjOfIibCtC2sHmuPRvzMaKkloEhYunKNHfaOEqC3nVgbaj6 NIlkVlioMe7RbWtAbHlm5Xqiu58N+3ihJCH8U9Im2HhmGMvbId/Rssx9UXoypBKzgx7F 7H4+0CSoJalIes6gcBUVX9RL1GMxX4w/rK0OqoxR24P9geGgJMvRHTwN32/5rJvUD61i eulg== X-Gm-Message-State: APzg51ABejv6OrKYI56Tl0Pkh74BIsXSBWtYvB50Q688rPARXWbxasPn 5kt7dQvGxfJDtsX+6I9w7xlOBw== X-Google-Smtp-Source: ANB0VdaolXqgkTk1j74RaNJWVtlME5XEPQFbIgHO75nLBJ1dS8+qJUQPg6SrobJtPyTnOzR5ZumfjA== X-Received: by 2002:a63:e647:: with SMTP id p7-v6mr10260017pgj.218.1535650575834; Thu, 30 Aug 2018 10:36:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:c8e0:70d7:4be7:a36]) by smtp.gmail.com with ESMTPSA id m15-v6sm11508335pfj.171.2018.08.30.10.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 10:36:14 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd , Taniya Das Cc: Douglas Anderson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Gross , David Brown , linux-soc@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH] clk: qcom: Allocate space for NULL terimation in DFS table Date: Thu, 30 Aug 2018 10:34:37 -0700 Message-Id: <20180830173437.63601-1-dianders@chromium.org> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The table allocated in clk_rcg2_dfs_populate_freq_table() is eventually iterated over by qcom_find_freq() which assumes that the table is NULL terminated. Allocate one extra space in the array for the NULL termination. Initting of the NULL termination is implicit due to kcalloc(). Fixes: cc4f6944d0e3 ("clk: qcom: Add support for RCG to register for DFS") Signed-off-by: Douglas Anderson --- drivers/clk/qcom/clk-rcg2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index d5d77f9ad170..6e3bd195d012 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -993,7 +993,8 @@ static int clk_rcg2_dfs_populate_freq_table(struct clk_rcg2 *rcg) struct freq_tbl *freq_tbl; int i; - freq_tbl = kcalloc(MAX_PERF_LEVEL, sizeof(*freq_tbl), GFP_KERNEL); + /* Allocate space for 1 extra since table is NULL terminated */ + freq_tbl = kcalloc(MAX_PERF_LEVEL + 1, sizeof(*freq_tbl), GFP_KERNEL); if (!freq_tbl) return -ENOMEM; rcg->freq_tbl = freq_tbl;