diff mbox series

[v1] drivers/pinctrl: Switch to use kmemdup_array()

Message ID 20240822044156.2301-1-shenlichuan@vivo.com
State New
Headers show
Series [v1] drivers/pinctrl: Switch to use kmemdup_array() | expand

Commit Message

Shen Lichuan Aug. 22, 2024, 4:41 a.m. UTC
Let the kememdup_array() take care about 
multiplication and possible overflows.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 drivers/pinctrl/pinctrl-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Linus Walleij Aug. 26, 2024, 8:28 a.m. UTC | #1
On Thu, Aug 22, 2024 at 6:42 AM Shen Lichuan <shenlichuan@vivo.com> wrote:

> Let the kememdup_array() take care about
> multiplication and possible overflows.
>
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>

Oh nice patch! Applied!

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-utils.c b/drivers/pinctrl/pinctrl-utils.c
index d81d7b46116c..f18903de1d71 100644
--- a/drivers/pinctrl/pinctrl-utils.c
+++ b/drivers/pinctrl/pinctrl-utils.c
@@ -70,8 +70,8 @@  int pinctrl_utils_add_map_configs(struct pinctrl_dev *pctldev,
 	if (WARN_ON(*num_maps == *reserved_maps))
 		return -ENOSPC;
 
-	dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs),
-			      GFP_KERNEL);
+	dup_configs = kmemdup_array(configs, num_configs,
+				sizeof(*dup_configs), GFP_KERNEL);
 	if (!dup_configs)
 		return -ENOMEM;