Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692504

[PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for mapping_table

From Kiran Gunda <kgunda@codeaurora.org>
Newsgroups linux.kernel
Subject [PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for mapping_table
Date 2017-07-20 09:40 +0200
Message-ID <u5edY-46l-11@gated-at.bofh.it> (permalink)
References <u5edY-46l-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
---
 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 0c98495..b32b5b0 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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for mapping_table Kiran Gunda <kgunda@codeaurora.org> - 2017-07-20 09:40 +0200
  Re: [PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for  mapping_table Stephen Boyd <sboyd@codeaurora.org> - 2017-07-28 01:50 +0200
    Re: [PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for  mapping_table Stephen Boyd <sboyd@codeaurora.org> - 2017-07-28 02:10 +0200
    Re: [PATCH V1 05/12] spmi: pmic-arb: fix memory allocation for  mapping_table kgunda@codeaurora.org - 2017-07-28 07:40 +0200

csiph-web