Skip to contentSkip to conversation

driver core: platform: Switch to use kmemdup_array()

PATCH New Andy Shevchenko 1 participant 1 message Jun 6, 2024 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: platform: Switch to use kmemdup_array()

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

---
 drivers/base/platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -1
index de89d8ca7cec..0ac3c7fa7f94 100644
@@ -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;
 	}
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac