2024-06-06 19:37:55

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/1] driver core: platform: Switch to use kmemdup_array()

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/base/platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index de89d8ca7cec..0ac3c7fa7f94 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -643,7 +643,7 @@ int platform_device_add_resources(struct platform_device *pdev,
struct resource *r = NULL;

if (res) {
- r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL);
+ r = kmemdup_array(res, num, sizeof(*r), GFP_KERNEL);
if (!r)
return -ENOMEM;
}
--
2.43.0.rc1.1336.g36b5255a03ac