[PATCH v1] drm/connector: Use kmemdup_array instead of kmemdup for multiple allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Yu Jiaoliang <yujiaoliang@xxxxxxxx>
---
 drivers/gpu/drm/drm_connector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index fc35f47e2849..dc1a5243dc90 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -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;
 	}
-- 
2.34.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux