Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ed3b394 authored by Markus Elfring's avatar Markus Elfring Committed by Sinclair Yeh
Browse files

drm/vmwgfx: Use kmalloc_array() in vmw_surface_define_ioctl()



Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
Signed-off-by: default avatarSinclair Yeh <syeh@vmware.com>
parent a1944030
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -763,13 +763,15 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
	memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels));
	srf->num_sizes = num_sizes;
	user_srf->size = size;

	srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
	srf->sizes = kmalloc_array(srf->num_sizes,
				   sizeof(*srf->sizes),
				   GFP_KERNEL);
	if (unlikely(srf->sizes == NULL)) {
		ret = -ENOMEM;
		goto out_no_sizes;
	}
	srf->offsets = kmalloc(srf->num_sizes * sizeof(*srf->offsets),
	srf->offsets = kmalloc_array(srf->num_sizes,
				     sizeof(*srf->offsets),
				     GFP_KERNEL);
	if (unlikely(srf->offsets == NULL)) {
		ret = -ENOMEM;