Skip to contentSkip to conversation

drm/nouveau/disp: switch to use kmemdup() helper

PATCH Applied [email protected] 2 participants 2 messages Jan 9, 2024 – Jan 10, 2024

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

PATCH v2 1/1 drm/nouveau/disp: switch to use kmemdup() helper

From: Chen Haonan <[email protected]>

Use kmemdup() helper instead of open-coding to
simplify the code.

---
 drivers/gpu/drm/nouveau/nvif/outp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nvif/outp.c +1 -2
index 5d3190c05250..6daeb7f0b09b 100644
@@ -452,13 +452,12 @@ nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 	if (ret)
 		goto done;
 
-	*pedid = kmalloc(args->size, GFP_KERNEL);
+	*pedid = kmemdup(args->data, args->size, GFP_KERNEL);
 	if (!*pedid) {
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	memcpy(*pedid, args->data, args->size);
 	ret = args->size;
 done:
 	kfree(args);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · On 1/9/24 07:24, [email protected] wrote:

From: Chen Haonan <[email protected]>

Use kmemdup() helper instead of open-coding to
simplify the code.

Applied to drm-misc-next, thanks!

Quoted 23 lines
---
  drivers/gpu/drm/nouveau/nvif/outp.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nvif/outp.c +1 -2
index 5d3190c05250..6daeb7f0b09b 100644
@@ -452,13 +452,12 @@ nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
  	if (ret)
  		goto done;
 
-	*pedid = kmalloc(args->size, GFP_KERNEL);
+	*pedid = kmemdup(args->data, args->size, GFP_KERNEL);
  	if (!*pedid) {
  		ret = -ENOMEM;
  		goto done;
  	}
 
-	memcpy(*pedid, args->data, args->size);
  	ret = args->size;
  done:
  	kfree(args);