Skip to contentSkip to conversation

drm/connector: Use kmemdup_array instead of kmemdup for multiple allocation

PATCH New Yu Jiaoliang 1 participant 1 message Aug 21, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/connector: Use kmemdup_array instead of kmemdup for multiple allocation

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

---
 drivers/gpu/drm/drm_connector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_connector.c +2 -2
index fc35f47e2849..dc1a5243dc90 100644
@@ -1025,8 +1025,8 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
 		return -EINVAL;
 
 	if (formats && num_formats) {
-		fmts = kmemdup(formats, sizeof(*formats) * num_formats,
-			       GFP_KERNEL);
+		fmts = kmemdup_array(formats, num_formats, sizeof(*formats),
+				     GFP_KERNEL);
 		if (!fmts)
 			return -ENOMEM;
 	}
Signature · 1 line
2.34.1