Skip to contentSkip to conversation

drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

PATCH In review Alex Dewar 3 participants 7 messages Sep 9, 2020 – Sep 21, 2020

Subsystems (3)
lore
Share & tools
lore

Alex Dewar

author
#0 lore raw

PATCH 1/1 drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Issue identified with Coccinelle.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
 	};
 	int i;
 
-	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
 	if (!dsi->debugfs_vpg)
 		return;
 
-	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
 	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
 		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
 				    dsi->debugfs, &dsi->debugfs_vpg[i],
Signature · 1 line
2.28.0
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Alex Dewar

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Issue identified with Coccinelle.

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0 -0
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
 	};
 	int i;
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void debugfs_create_files(void *data) · line 1058

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
-	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
 	if (!dsi->debugfs_vpg)
 		return;
 
-	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
 	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
 		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
 				    dsi->debugfs, &dsi->debugfs_vpg[i],

Thanks,
Neil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#2 lore raw
Quoted 3 lines · Neil Armstrong
Quoted 2 lines · Alex Dewar

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Friendly ping?

Quoted 31 lines
Quoted 17 lines

Issue identified with Coccinelle.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0 -0
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
  	};
  	int i;
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void debugfs_create_files(void *data) · line 1058

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
-	dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+	dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
  	if (!dsi->debugfs_vpg)
  		return;
 
-	memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
  	for (i = 0; i < ARRAY_SIZE(debugfs); i++)
  		debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
  				    dsi->debugfs, &dsi->debugfs_vpg[i],

Thanks,
Neil

#3 lore raw
Quoted 34 lines · Alex Dewar
Quoted 3 lines · Neil Armstrong
Quoted 2 lines · Alex Dewar

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Friendly ping?

Quoted 28 lines
Quoted 17 lines

Issue identified with Coccinelle.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0 -0
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
     };
     int i;
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void debugfs_create_files(void *data) · line 1058

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
-    dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+    dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
     if (!dsi->debugfs_vpg)
             return;
 
-    memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
     for (i = 0; i < ARRAY_SIZE(debugfs); i++)
             debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
                                 dsi->debugfs, &dsi->debugfs_vpg[i],

Neil has commit rights, so I was assuming he'd push this to drm-misc-next. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#4 lore raw
Quoted 36 lines · Daniel Vetter
Quoted 34 lines · Alex Dewar
Quoted 3 lines · Neil Armstrong
Quoted 2 lines · Alex Dewar

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Friendly ping?

Quoted 28 lines
Quoted 17 lines

Issue identified with Coccinelle.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0 -0
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
     };
     int i;
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void debugfs_create_files(void *data) · line 1058

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
-    dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+    dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
     if (!dsi->debugfs_vpg)
             return;
 
-    memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
     for (i = 0; i < ARRAY_SIZE(debugfs); i++)
             debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
                                 dsi->debugfs, &dsi->debugfs_vpg[i],
Quoted 3 lines

Neil has commit rights, so I was assuming he'd push this to drm-misc-next. -Daniel

Applying now,
Neil

#5 lore raw
In reply to Daniel Vetter
Quoted 36 lines · Daniel Vetter
Quoted 34 lines · Alex Dewar
Quoted 3 lines · Neil Armstrong
Quoted 2 lines · Alex Dewar

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Friendly ping?

Quoted 28 lines
Quoted 17 lines

Issue identified with Coccinelle.

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +0 -0
index 52f5c5a2ed64..7e9a62ad56e8 100644
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
     };
     int i;
 

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static void debugfs_create_files(void *data) · line 1058

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +1 -3
-    dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+    dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
     if (!dsi->debugfs_vpg)
             return;
 
-    memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
     for (i = 0; i < ARRAY_SIZE(debugfs); i++)
             debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
                                 dsi->debugfs, &dsi->debugfs_vpg[i],
Quoted 3 lines

Neil has commit rights, so I was assuming he'd push this to drm-misc-next. -Daniel

Hmm, I applied this already:
commit 33f290811d4c1a09c4e92f5bf0458525835dbcba

Author: Alex Dewar <[email protected]>
Date:   Wed Sep 9 20:02:08 2020 +0100

drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Issue identified with Coccinelle.

Neil

author
#6 lore raw
Quoted 11 lines

Hmm, I applied this already:
commit 33f290811d4c1a09c4e92f5bf0458525835dbcba

Author: Alex Dewar <[email protected]>
Date:   Wed Sep 9 20:02:08 2020 +0100

drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of this pattern.

Quoted 8 lines

Issue identified with Coccinelle.

Neil

Sorry! My bad. Thanks for applying :)

Alex