[PATCH] drm/lima: fix memdup.cocci warnings

kbuild test robot lkp at intel.com
Mon Feb 25 18:39:28 UTC 2019


From: kbuild test robot <lkp at intel.com>

drivers/gpu/drm/lima/lima_sched.c:115:13-20: WARNING opportunity for kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: ef1d65006858 ("drm/lima: driver for ARM Mali4xx GPUs")
CC: Qiang Yu <yuq825 at gmail.com>
Signed-off-by: kbuild test robot <fengguang.wu at intel.com>
---

url:    https://github.com/0day-ci/linux/commits/Qiang-Yu/drm-export-drm_timeout_abs_to_jiffies/20190226-010350

Please take the patch only if it's a positive warning. Thanks!

 lima_sched.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -112,10 +112,9 @@ int lima_sched_task_init(struct lima_sch
 {
 	int err, i;
 
-	task->bos = kmalloc(sizeof(*bos) * num_bos, GFP_KERNEL);
+	task->bos = kmemdup(bos, sizeof(*bos) * num_bos, GFP_KERNEL);
 	if (!task->bos)
 		return -ENOMEM;
-	memcpy(task->bos, bos, sizeof(*bos) * num_bos);
 
 	for (i = 0; i < num_bos; i++)
 		drm_gem_object_get(&bos[i]->gem);


More information about the dri-devel mailing list