* [PATCH v2] platform/chrome: chromeos_laptop: Use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-21 11:26 Yu Jiaoliang
2024-08-22 12:26 ` Tzung-Bi Shih
0 siblings, 1 reply; 3+ messages in thread
From: Yu Jiaoliang @ 2024-08-21 11:26 UTC (permalink / raw)
To: Benson Leung, Tzung-Bi Shih, chrome-platform, linux-kernel
Cc: opensource.kernel
Let the kememdup_array() take care about multiplication and possible
overflows.
v2:
-Use sizeof(*i2c_peripherals) instead of sizeof(*src->i2c_peripherals)
-Format code
Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/platform/chrome/chromeos_laptop.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index a2cdbfbaeae6..3ab668764383 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -749,10 +749,9 @@ chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
if (!src->num_i2c_peripherals)
return 0;
- i2c_peripherals = kmemdup(src->i2c_peripherals,
- src->num_i2c_peripherals *
- sizeof(*src->i2c_peripherals),
- GFP_KERNEL);
+ i2c_peripherals = kmemdup_array(src->i2c_peripherals,
+ src->num_i2c_peripherals,
+ sizeof(*i2c_peripherals), GFP_KERNEL);
if (!i2c_peripherals)
return -ENOMEM;
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] platform/chrome: chromeos_laptop: Use kmemdup_array instead of kmemdup for multiple allocation
2024-08-21 11:26 [PATCH v2] platform/chrome: chromeos_laptop: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
@ 2024-08-22 12:26 ` Tzung-Bi Shih
2024-08-23 7:27 ` 于佼良
0 siblings, 1 reply; 3+ messages in thread
From: Tzung-Bi Shih @ 2024-08-22 12:26 UTC (permalink / raw)
To: Yu Jiaoliang
Cc: Benson Leung, chrome-platform, linux-kernel, opensource.kernel
On Wed, Aug 21, 2024 at 07:26:29PM +0800, Yu Jiaoliang wrote:
> v2:
> -Use sizeof(*i2c_peripherals) instead of sizeof(*src->i2c_peripherals)
> -Format code
Please move the changelogs after "---" next time so that they won't be part of
commit message.
> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
I didn't see the tag was provided in the mailing list.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] platform/chrome: chromeos_laptop: Use kmemdup_array instead of kmemdup for multiple allocation
2024-08-22 12:26 ` Tzung-Bi Shih
@ 2024-08-23 7:27 ` 于佼良
0 siblings, 0 replies; 3+ messages in thread
From: 于佼良 @ 2024-08-23 7:27 UTC (permalink / raw)
To: Tzung-Bi Shih
Cc: Benson Leung, chrome-platform, linux-kernel, opensource.kernel
在 2024/8/22 20:26, Tzung-Bi Shih 写道:
> On Wed, Aug 21, 2024 at 07:26:29PM +0800, Yu Jiaoliang wrote:
>> v2:
>> -Use sizeof(*i2c_peripherals) instead of sizeof(*src->i2c_peripherals)
>> -Format code
> Please move the changelogs after "---" next time so that they won't be part of
> commit message.
>
>> Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> I didn't see the tag was provided in the mailing list.
Hi,
I've updated the position of the changelogs and R-b tags. Thanks~
Best Regards,
Yu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-23 7:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21 11:26 [PATCH v2] platform/chrome: chromeos_laptop: Use kmemdup_array instead of kmemdup for multiple allocation Yu Jiaoliang
2024-08-22 12:26 ` Tzung-Bi Shih
2024-08-23 7:27 ` 于佼良
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®