Skip to contentSkip to conversation

drm/syncobj: Reformat kmalloc for chains

PATCH In review Jonathan Cavitt 2 participants 2 messages Jun 30 – Jul 1

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

PATCH 1/1 drm/syncobj: Reformat kmalloc for chains

We should use sizeof(*chains) instead of sizeof(void *) when performing the kmalloc for chains in drm_syncobj_timeline_signal_ioctl, stylistically speaking. Also, wrap the line to match how the variable points is allocated.

Concern caught by static analysis.

Cc Tobias Hector <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Christian König <[email protected]>
Cc Chunming Zhou <[email protected]>
Cc Lionel Landwerlin <[email protected]>
---
 drivers/gpu/drm/drm_syncobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_syncobj.c +2 -1
index c9dbf64c0c9f..d4c5b97403ee 100644
@@ -1619,7 +1619,8 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
 		goto err_points;
 	}
 
-	chains = kmalloc_array(args->count_handles, sizeof(void *), GFP_KERNEL);
+	chains = kmalloc_array(args->count_handles, sizeof(*chains),
+			       GFP_KERNEL);
 	if (!chains) {
 		ret = -ENOMEM;
 		goto err_points;
Signature · 1 line
2.53.0
#1 lore raw
Quoted 24 lines · Jonathan Cavitt

We should use sizeof(*chains) instead of sizeof(void *) when performing the kmalloc for chains in drm_syncobj_timeline_signal_ioctl, stylistically speaking. Also, wrap the line to match how the variable points is allocated.

Concern caught by static analysis.

Cc Tobias Hector <[email protected]>
Cc Jason Ekstrand <[email protected]>
Cc Dave Airlie <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Christian König <[email protected]>
Cc Chunming Zhou <[email protected]>
Cc Lionel Landwerlin <[email protected]>
---
 drivers/gpu/drm/drm_syncobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_syncobj.c +0 -0
index c9dbf64c0c9f..d4c5b97403ee 100644

drivers/gpu/drm/drm_syncobj.c drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data, · line 1623

Quoted 6 lines
drivers/gpu/drm/drm_syncobj.c +2 -1
@@ -1619,7 +1619,8 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
 		goto err_points;
 	}
 
-	chains = kmalloc_array(args->count_handles, sizeof(void *), GFP_KERNEL);
+	chains = kmalloc_array(args->count_handles, sizeof(*chains),
+			       GFP_KERNEL);

We should probably use kmalloc_objs() instead here.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/drm_syncobj.c +0 -0
 	if (!chains) {
 		ret = -ENOMEM;
 		goto err_points;