diff mbox series

[v1] drivers/pinctrl/freescale: Use kmemdup_array instead of kmemdup for multiple allocation

Message ID 20240823013959.6281-1-shenlichuan@vivo.com (mailing list archive)
State New
Headers show
Series [v1] drivers/pinctrl/freescale: Use kmemdup_array instead of kmemdup for multiple allocation | expand

Commit Message

Shen Lichuan Aug. 23, 2024, 1:39 a.m. UTC
Let the kememdup_array() take care about
multiplication and possible overflows.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 drivers/pinctrl/freescale/pinctrl-imx-scmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peng Fan Aug. 23, 2024, 9:16 a.m. UTC | #1
> Subject: [PATCH v1] drivers/pinctrl/freescale: Use kmemdup_array
> instead of kmemdup for multiple allocation

Nit: subject prefix:
"pinctrl: freescale: imx-scmi:" 

Reviewed-by: Peng Fan <peng.fan@nxp.com>

Regards,
Peng.
>
Andy Shevchenko Aug. 23, 2024, 3:19 p.m. UTC | #2
On Fri, Aug 23, 2024 at 09:39:59AM +0800, Shen Lichuan wrote:
> Let the kememdup_array() take care about

kmemdup_array()

> multiplication and possible overflows.
diff mbox series

Patch

diff --git a/drivers/pinctrl/freescale/pinctrl-imx-scmi.c b/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
index 2991047535bc..8f15c4c4dc44 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx-scmi.c
@@ -130,7 +130,7 @@  static int pinctrl_scmi_imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 			cfg[j++] = pinconf_to_config_packed(IMX_SCMI_PIN_DAISY_CFG, input_val);
 		}
 
-		configs = kmemdup(cfg, ncfg * sizeof(unsigned long), GFP_KERNEL);
+		configs = kmemdup_array(cfg, ncfg, sizeof(unsigned long), GFP_KERNEL);
 
 		new_map[i].type = PIN_MAP_TYPE_CONFIGS_PIN;
 		new_map[i].data.configs.group_or_pin = pin_get_name(pctldev, pin_id);