linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-23 11:44 Shen Lichuan
  2024-08-23 13:41 ` Krzysztof Kozlowski
  2024-08-23 13:42 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Shen Lichuan @ 2024-08-23 11:44 UTC (permalink / raw)
  To: krzk, s.nawrocki, linus.walleij
  Cc: alim.akhtar, linux-arm-kernel, linux-samsung-soc, linux-gpio,
	linux-kernel, opensource.kernel, Shen Lichuan

Let the kmemdup_array() take care about multiplication
and possible overflows.

Using kmemdup_array() is more appropriate and makes the code
easier to audit.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
v1->v2: modified commit message and code format according to Linux coding style and submission process
---
 drivers/pinctrl/samsung/pinctrl-samsung.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index e4464ee815f9..675efa5d86a9 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -122,8 +122,8 @@ static int add_map_configs(struct device *dev, struct pinctrl_map **map,
 	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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-23 11:44 [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
@ 2024-08-23 13:41 ` Krzysztof Kozlowski
  2024-08-23 13:42 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-23 13:41 UTC (permalink / raw)
  To: krzk, s.nawrocki, linus.walleij, Shen Lichuan
  Cc: alim.akhtar, linux-arm-kernel, linux-samsung-soc, linux-gpio,
	linux-kernel, opensource.kernel


On Fri, 23 Aug 2024 19:44:41 +0800, Shen Lichuan wrote:
> Let the kmemdup_array() take care about multiplication
> and possible overflows.
> 
> Using kmemdup_array() is more appropriate and makes the code
> easier to audit.
> 
> 
> [...]

Applied, thanks!

[1/1] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
      https://git.kernel.org/pinctrl/samsung/c/39dbbd4e6778ac5580313ba34409855250633c61

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation
  2024-08-23 11:44 [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
  2024-08-23 13:41 ` Krzysztof Kozlowski
@ 2024-08-23 13:42 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-23 13:42 UTC (permalink / raw)
  To: Shen Lichuan, s.nawrocki, linus.walleij
  Cc: alim.akhtar, linux-arm-kernel, linux-samsung-soc, linux-gpio,
	linux-kernel, opensource.kernel

On 23/08/2024 13:44, Shen Lichuan wrote:
> Let the kmemdup_array() take care about multiplication
> and possible overflows.
> 
> Using kmemdup_array() is more appropriate and makes the code
> easier to audit.
> 
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> ---
> v1->v2: modified commit message and code format according to Linux coding style and submission process
> ---
>  drivers/pinctrl/samsung/pinctrl-samsung.c | 4 ++--

I missed last time, subject is without "drivers:". I think only few
subsystems expect drivers.

You can get prefix for example with `git log --oneline --
DIRECTORY_OR_FILE` on the directory your patch is touching.

No need to resend, fixed up.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-23 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-23 11:44 [PATCH v2] drivers: pinctrl: samsung: Use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
2024-08-23 13:41 ` Krzysztof Kozlowski
2024-08-23 13:42 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).