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: 10582417 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 65DF75A4 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 518812C332 for ; Thu, 30 Aug 2018 17:36:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 435ED2C336; 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=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 397E12C2E5 for ; Thu, 30 Aug 2018 17:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbeH3Vj3 (ORCPT ); Thu, 30 Aug 2018 17:39:29 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34198 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727470AbeH3Vj3 (ORCPT ); Thu, 30 Aug 2018 17:39:29 -0400 Received: by mail-pg1-f194.google.com with SMTP id d19-v6so4207971pgv.1 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=N8JgAZhBqQJSsnSu5QtAsvOMIFU9Y1lFwyVHDpWFOtpLmEu/1tIaLCoOTPNmCvr+u/ uFu4q8hIIlUABwNRMzo7MwXvwvsVxsFm7K+qJPYfHnM8auS9DaUcglOi9xqgeYbHmMZR 4IXb1T6KAlum0bIyGDAAhKFCNd8WygEjjRivYzkvFtVDlBMgNPEvJ+Yy2PNONW1tl12v xuEQng5u+tTK3/FYqyKFeBhEtVkHokdqwmjjXvJvWWPLJvgSRd9k8BVmowBvdOMOhnYd 2o5VioCfrT0cEA6plAWx0GjZE86lNInUKBwsl2HnxWWK9at6VvpGoLIqVMv0qeuXHDe2 4fxw== X-Gm-Message-State: APzg51C6DN/pCH4FMfhdpnqn4jKInL9GuEmJM6b/EyuKOfs+TxoeKeMV 4hhsAWdrGDoQU2KalEGVKYYSaA== 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-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@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;