Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751882AbdG1HMF (ORCPT ); Fri, 28 Jul 2017 03:12:05 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47756 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbdG1HMC (ORCPT ); Fri, 28 Jul 2017 03:12:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 491CB609D1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=kgunda@codeaurora.org From: Kiran Gunda To: gregkh@linuxfoundation.org, sboyd@codeaurora.org, Kiran Gunda , Abhijeet Dharmapurikar , David Collins , linux-kernel@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org Subject: [PATCH V2 05/12] spmi: pmic-arb: fix memory allocation for mapping_table Date: Fri, 28 Jul 2017 12:40:40 +0530 Message-Id: <1501225847-27807-6-git-send-email-kgunda@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501225847-27807-1-git-send-email-kgunda@codeaurora.org> References: <1501225847-27807-1-git-send-email-kgunda@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1651 Lines: 47 Allocate the correct memory size (max_pmic_peripherals) for the mapping_table that holds the apid to ppid mapping. Also use a local variable for mapping_table for better alignment of the code. Fixes: 987a9f128b8a ("spmi: pmic-arb: Support more than 128 peripherals") Signed-off-by: Kiran Gunda Reviewed-by: Stephen Boyd --- drivers/spmi/spmi-pmic-arb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index 0577cfd..340e7b8 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -929,6 +929,7 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) struct spmi_controller *ctrl; struct resource *res; void __iomem *core; + u32 *mapping_table; u32 channel, ee, hw_ver; int err; @@ -1038,16 +1039,14 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) } pmic_arb->ee = ee; - - pmic_arb->mapping_table = devm_kcalloc(&ctrl->dev, - PMIC_ARB_MAX_PERIPHS - 1, - sizeof(*pmic_arb->mapping_table), - GFP_KERNEL); - if (!pmic_arb->mapping_table) { + mapping_table = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PERIPHS, + sizeof(*mapping_table), GFP_KERNEL); + if (!mapping_table) { err = -ENOMEM; goto err_put_ctrl; } + pmic_arb->mapping_table = mapping_table; /* Initialize max_apid/min_apid to the opposite bounds, during * the irq domain translation, we are sure to update these */ pmic_arb->max_apid = 0; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project