linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/31] use kmemdup rather than duplicating its implementation
@ 2015-08-07  7:59 Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 01/31] arch/arm/mach-lpc32xx: " Andrzej Hajda
                   ` (30 more replies)
  0 siblings, 31 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski

Hi,

This patchset was created using fixed version of memdup.cocci
semantic patch [1]. It was compile tested only.

It is based on latest linux-next.

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Regards
Andrzej


Andrzej Hajda (31):
  arch/arm/mach-lpc32xx: use kmemdup rather than duplicating its
    implementation
  arch/ia64/tioce: use kmemdup rather than duplicating its
    implementation
  arch/m68k/bootinfo: use kmemdup rather than duplicating its
    implementation
  arch/mips/bcm47xx: use kmemdup rather than duplicating its
    implementation
  arch/powerpc/nvram: use kmemdup rather than duplicating its
    implementation
  arch/powerpc/pseries: use kmemdup rather than duplicating its
    implementation
  arch/x86/microcode: use kmemdup rather than duplicating its
    implementation
  arch/x86/intel-mid: use kmemdup rather than duplicating its
    implementation
  crypto: use kmemdup rather than duplicating its implementation
  clk/mmp: use kmemdup rather than duplicating its implementation
  cpufreq/sfi: use kmemdup rather than duplicating its implementation
  drm/amdgpu: use kmemdup rather than duplicating its implementation
  memstick: use kmemdup rather than duplicating its implementation
  message/fusion: use kmemdup rather than duplicating its implementation
  misc/vmw_vmci: use kmemdup rather than duplicating its implementation
  net/cavium/liquidio: use kmemdup rather than duplicating its
    implementation
  scsi/aacraid: use kmemdup rather than duplicating its implementation
  scsi/aic7xxx: use kmemdup rather than duplicating its implementation
  staging/lustre: use kmemdup rather than duplicating its implementation
  fs/cifs: use kmemdup rather than duplicating its implementation
  fs/dlm: use kmemdup rather than duplicating its implementation
  fs/ntfs: use kmemdup rather than duplicating its implementation
  fs/ocfs2: use kmemdup rather than duplicating its implementation
  fs/omfs: use kmemdup rather than duplicating its implementation
  fs/ubifs: use kmemdup rather than duplicating its implementation
  net/sched: use kmemdup rather than duplicating its implementation
  net/tipc: use kmemdup rather than duplicating its implementation
  net/xfrm: use kmemdup rather than duplicating its implementation
  sound/oxfw: use kmemdup rather than duplicating its implementation
  sound/atom: use kmemdup rather than duplicating its implementation
  sound/soc: use kmemdup rather than duplicating its implementation

 arch/arm/mach-lpc32xx/pm.c                           | 7 ++-----
 arch/ia64/sn/pci/tioce_provider.c                    | 4 ++--
 arch/m68k/kernel/bootinfo_proc.c                     | 4 +---
 arch/mips/bcm47xx/buttons.c                          | 3 +--
 arch/powerpc/kernel/nvram_64.c                       | 3 +--
 arch/powerpc/platforms/pseries/hotplug-memory.c      | 3 +--
 arch/x86/kernel/cpu/microcode/amd.c                  | 4 +---
 arch/x86/kernel/cpu/microcode/intel_early.c          | 4 +---
 arch/x86/platform/intel-mid/sfi.c                    | 3 +--
 crypto/echainiv.c                                    | 7 ++-----
 crypto/seqiv.c                                       | 6 ++----
 drivers/clk/mmp/clk-mix.c                            | 7 +++----
 drivers/cpufreq/sfi-cpufreq.c                        | 4 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c           | 4 +---
 drivers/memstick/core/mspro_block.c                  | 3 +--
 drivers/message/fusion/mptbase.c                     | 3 +--
 drivers/misc/vmw_vmci/vmci_datagram.c                | 3 +--
 drivers/net/ethernet/cavium/liquidio/octeon_device.c | 4 +---
 drivers/scsi/aacraid/commctrl.c                      | 7 +++----
 drivers/scsi/aic7xxx/aic79xx_core.c                  | 4 ++--
 drivers/scsi/aic7xxx/aic7xxx_core.c                  | 4 ++--
 drivers/staging/lustre/lustre/obdclass/acl.c         | 6 ++----
 fs/cifs/smb2pdu.c                                    | 5 ++---
 fs/dlm/lowcomms.c                                    | 3 +--
 fs/ntfs/dir.c                                        | 7 +++----
 fs/ocfs2/localalloc.c                                | 6 ++----
 fs/omfs/inode.c                                      | 3 +--
 fs/ubifs/lpt.c                                       | 6 ++----
 fs/ubifs/tnc.c                                       | 3 +--
 net/sched/act_bpf.c                                  | 4 +---
 net/sched/cls_bpf.c                                  | 4 +---
 net/tipc/server.c                                    | 3 +--
 net/xfrm/xfrm_user.c                                 | 6 ++----
 sound/firewire/oxfw/oxfw-stream.c                    | 9 +++------
 sound/soc/intel/atom/sst/sst_ipc.c                   | 3 +--
 sound/soc/soc-topology.c                             | 6 +++---
 36 files changed, 57 insertions(+), 108 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [PATCH 01/31] arch/arm/mach-lpc32xx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16  9:52   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 02/31] arch/ia64/tioce: " Andrzej Hajda
                   ` (29 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Roland Stigge
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-arm-kernel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/arm/mach-lpc32xx/pm.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index 207e812..dd3a432 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -87,7 +87,8 @@ static int lpc32xx_pm_enter(suspend_state_t state)
 	void *iram_swap_area;
 
 	/* Allocate some space for temporary IRAM storage */
-	iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
+	iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA,
+				 lpc32xx_sys_suspend_sz, GFP_KERNEL);
 	if (!iram_swap_area) {
 		printk(KERN_ERR
 		       "PM Suspend: cannot allocate memory to save portion "
@@ -95,10 +96,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
 		return -ENOMEM;
 	}
 
-	/* Backup a small area of IRAM used for the suspend code */
-	memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
-		lpc32xx_sys_suspend_sz);
-
 	/*
 	 * Copy code to suspend system into IRAM. The suspend code
 	 * needs to run from IRAM as DRAM may no longer be available
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 02/31] arch/ia64/tioce: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 01/31] arch/arm/mach-lpc32xx: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16  9:53   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 03/31] arch/m68k/bootinfo: " Andrzej Hajda
                   ` (28 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-ia64

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/ia64/sn/pci/tioce_provider.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
index 46d3df4..2f13276 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -1000,11 +1000,11 @@ tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
 	 * Allocate kernel bus soft and copy from prom.
 	 */
 
-	tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL);
+	tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common),
+			       GFP_KERNEL);
 	if (!tioce_common)
 		return NULL;
 
-	memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common));
 	tioce_common->ce_pcibus.bs_base = (unsigned long)
 		ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base),
 			sizeof(struct tioce_common));
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 03/31] arch/m68k/bootinfo: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 01/31] arch/arm/mach-lpc32xx: " Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 02/31] arch/ia64/tioce: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 10:23   ` Geert Uytterhoeven
  2015-08-07  7:59 ` [PATCH 04/31] arch/mips/bcm47xx: " Andrzej Hajda
                   ` (27 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-m68k

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/m68k/kernel/bootinfo_proc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/m68k/kernel/bootinfo_proc.c b/arch/m68k/kernel/bootinfo_proc.c
index 7ee853e..2a33a96 100644
--- a/arch/m68k/kernel/bootinfo_proc.c
+++ b/arch/m68k/kernel/bootinfo_proc.c
@@ -62,12 +62,10 @@ static int __init init_bootinfo_procfs(void)
 	if (!bootinfo_size)
 		return -EINVAL;
 
-	bootinfo_copy = kmalloc(bootinfo_size, GFP_KERNEL);
+	bootinfo_copy = kmemdup(bootinfo_tmp, bootinfo_size, GFP_KERNEL);
 	if (!bootinfo_copy)
 		return -ENOMEM;
 
-	memcpy(bootinfo_copy, bootinfo_tmp, bootinfo_size);
-
 	pde = proc_create_data("bootinfo", 0400, NULL, &bootinfo_fops, NULL);
 	if (!pde) {
 		kfree(bootinfo_copy);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 04/31] arch/mips/bcm47xx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (2 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 03/31] arch/m68k/bootinfo: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-09 20:14   ` Hauke Mehrtens
  2015-08-07  7:59 ` [PATCH 05/31] arch/powerpc/nvram: " Andrzej Hajda
                   ` (26 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Hauke Mehrtens, Rafał Miłecki
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-mips, Ralf Baechle

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/mips/bcm47xx/buttons.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/mips/bcm47xx/buttons.c b/arch/mips/bcm47xx/buttons.c
index 08a4abf..52caa75 100644
--- a/arch/mips/bcm47xx/buttons.c
+++ b/arch/mips/bcm47xx/buttons.c
@@ -396,10 +396,9 @@ static int __init bcm47xx_buttons_copy(const struct gpio_keys_button *buttons,
 {
 	size_t size = nbuttons * sizeof(*buttons);
 
-	bcm47xx_button_pdata.buttons = kmalloc(size, GFP_KERNEL);
+	bcm47xx_button_pdata.buttons = kmemdup(buttons, size, GFP_KERNEL);
 	if (!bcm47xx_button_pdata.buttons)
 		return -ENOMEM;
-	memcpy(bcm47xx_button_pdata.buttons, buttons, size);
 	bcm47xx_button_pdata.nbuttons = nbuttons;
 
 	return 0;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 05/31] arch/powerpc/nvram: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (3 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 04/31] arch/mips/bcm47xx: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 19:46   ` Nathan Fontenot
  2015-08-19 23:14   ` [05/31] " Michael Ellerman
  2015-08-07  7:59 ` [PATCH 06/31] arch/powerpc/pseries: " Andrzej Hajda
                   ` (25 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linuxppc-dev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/powerpc/kernel/nvram_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 1e703f8..6f6597b 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -541,10 +541,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
 			time->tv_sec = be64_to_cpu(oops_hdr->timestamp);
 			time->tv_nsec = 0;
 		}
-		*buf = kmalloc(length, GFP_KERNEL);
+		*buf = kmemdup(buff + hdr_size, length, GFP_KERNEL);
 		if (*buf == NULL)
 			return -ENOMEM;
-		memcpy(*buf, buff + hdr_size, length);
 		kfree(buff);
 
 		if (err_type == ERR_TYPE_KERNEL_PANIC_GZ)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 06/31] arch/powerpc/pseries: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (4 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 05/31] arch/powerpc/nvram: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 19:46   ` Nathan Fontenot
  2015-08-19 23:14   ` [06/31] " Michael Ellerman
  2015-08-07  7:59 ` [PATCH 07/31] arch/x86/microcode: " Andrzej Hajda
                   ` (24 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linuxppc-dev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/powerpc/platforms/pseries/hotplug-memory.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 0ced387..e9ff44c 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -92,13 +92,12 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 		return NULL;
 
 	new_prop->name = kstrdup(prop->name, GFP_KERNEL);
-	new_prop->value = kmalloc(prop->length, GFP_KERNEL);
+	new_prop->value = kmemdup(prop->value, prop->length, GFP_KERNEL);
 	if (!new_prop->name || !new_prop->value) {
 		dlpar_free_drconf_property(new_prop);
 		return NULL;
 	}
 
-	memcpy(new_prop->value, prop->value, prop->length);
 	new_prop->length = prop->length;
 
 	/* Convert the property to cpu endian-ness */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (5 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 06/31] arch/powerpc/pseries: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 16:30   ` Borislav Petkov
  2015-08-07  7:59 ` [PATCH 08/31] arch/x86/intel-mid: " Andrzej Hajda
                   ` (23 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, x86

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/x86/kernel/cpu/microcode/amd.c         | 4 +---
 arch/x86/kernel/cpu/microcode/intel_early.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index c7d2415..be37f10 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -366,15 +366,13 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
 		return -EINVAL;
 	}
 
-	patch->data = kzalloc(patch_size, GFP_KERNEL);
+	patch->data = kmemdup(fw + SECTION_HDR_SIZE, patch_size, GFP_KERNEL);
 	if (!patch->data) {
 		pr_err("Patch data allocation failure.\n");
 		kfree(patch);
 		return -EINVAL;
 	}
 
-	/* All looks ok, copy patch... */
-	memcpy(patch->data, fw + SECTION_HDR_SIZE, patch_size);
 	INIT_LIST_HEAD(&patch->plist);
 	patch->patch_id  = mc_hdr->patch_id;
 	patch->equiv_cpu = proc_id;
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c
index 37ea89c..3f843f1 100644
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -207,13 +207,11 @@ save_microcode(struct mc_saved_data *mc_saved_data,
 		mc_hdr = &mc->hdr;
 		size   = get_totalsize(mc_hdr);
 
-		saved_ptr[i] = kmalloc(size, GFP_KERNEL);
+		saved_ptr[i] = kmemdup(mc, size, GFP_KERNEL);
 		if (!saved_ptr[i]) {
 			ret = -ENOMEM;
 			goto err;
 		}
-
-		memcpy(saved_ptr[i], mc, size);
 	}
 
 	/*
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 08/31] arch/x86/intel-mid: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (6 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 07/31] arch/x86/microcode: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16  9:54   ` Andrzej Hajda
  2015-09-17 21:42   ` [tip:x86/platform] arch/x86/intel-mid: Use " tip-bot for Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 09/31] crypto: use " Andrzej Hajda
                   ` (22 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, x86

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 arch/x86/platform/intel-mid/sfi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index ce992e8..5ee360a 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -197,10 +197,9 @@ static int __init sfi_parse_gpio(struct sfi_table_header *table)
 	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
 	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
 
-	gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL);
+	gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL);
 	if (!gpio_table)
 		return -1;
-	memcpy(gpio_table, pentry, num * sizeof(*pentry));
 	gpio_num_entry = num;
 
 	pr_debug("GPIO pin info:\n");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 09/31] crypto: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (7 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 08/31] arch/x86/intel-mid: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07  8:05   ` Herbert Xu
  2015-08-07  7:59 ` [PATCH 10/31] clk/mmp: " Andrzej Hajda
                   ` (21 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-crypto

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 crypto/echainiv.c | 7 ++-----
 crypto/seqiv.c    | 6 ++----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/crypto/echainiv.c b/crypto/echainiv.c
index d3896c7..d8968c0 100644
--- a/crypto/echainiv.c
+++ b/crypto/echainiv.c
@@ -134,13 +134,10 @@ static int echainiv_encrypt(struct aead_request *req)
 
 	if (unlikely(!IS_ALIGNED((unsigned long)info,
 				 crypto_aead_alignmask(geniv) + 1))) {
-		info = kmalloc(ivsize, req->base.flags &
-				       CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL:
-								  GFP_ATOMIC);
+		info = kmemdup(req->iv, ivsize,
+			       req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC);
 		if (!info)
 			return -ENOMEM;
-
-		memcpy(info, req->iv, ivsize);
 	}
 
 	aead_request_set_callback(subreq, req->base.flags, compl, data);
diff --git a/crypto/seqiv.c b/crypto/seqiv.c
index 45d0563..eb83236 100644
--- a/crypto/seqiv.c
+++ b/crypto/seqiv.c
@@ -362,13 +362,11 @@ static int seqiv_aead_encrypt(struct aead_request *req)
 
 	if (unlikely(!IS_ALIGNED((unsigned long)info,
 				 crypto_aead_alignmask(geniv) + 1))) {
-		info = kmalloc(ivsize, req->base.flags &
-				       CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL:
-								  GFP_ATOMIC);
+		info = kmemdup(req->iv, ivsize,
+			       req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC);
 		if (!info)
 			return -ENOMEM;
 
-		memcpy(info, req->iv, ivsize);
 		compl = seqiv_aead_encrypt_complete;
 		data = req;
 	}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 10/31] clk/mmp: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (8 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 09/31] crypto: use " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 22:17   ` Stephen Boyd
  2015-08-07  7:59 ` [PATCH 11/31] cpufreq/sfi: " Andrzej Hajda
                   ` (20 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-clk

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/clk/mmp/clk-mix.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c
index 665cb67..3383410 100644
--- a/drivers/clk/mmp/clk-mix.c
+++ b/drivers/clk/mmp/clk-mix.c
@@ -469,20 +469,20 @@ struct clk *mmp_clk_register_mix(struct device *dev,
 	memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info));
 	if (config->table) {
 		table_bytes = sizeof(*config->table) * config->table_size;
-		mix->table = kzalloc(table_bytes, GFP_KERNEL);
+		mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL);
 		if (!mix->table) {
 			pr_err("%s:%s: could not allocate mmp mix table\n",
 				__func__, name);
 			kfree(mix);
 			return ERR_PTR(-ENOMEM);
 		}
-		memcpy(mix->table, config->table, table_bytes);
 		mix->table_size = config->table_size;
 	}
 
 	if (config->mux_table) {
 		table_bytes = sizeof(u32) * num_parents;
-		mix->mux_table = kzalloc(table_bytes, GFP_KERNEL);
+		mix->mux_table = kmemdup(config->mux_table, table_bytes,
+					 GFP_KERNEL);
 		if (!mix->mux_table) {
 			pr_err("%s:%s: could not allocate mmp mix mux-table\n",
 				__func__, name);
@@ -490,7 +490,6 @@ struct clk *mmp_clk_register_mix(struct device *dev,
 			kfree(mix);
 			return ERR_PTR(-ENOMEM);
 		}
-		memcpy(mix->mux_table, config->mux_table, table_bytes);
 	}
 
 	mix->div_flags = config->div_flags;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 11/31] cpufreq/sfi: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (9 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 10/31] clk/mmp: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07  8:58   ` Viresh Kumar
  2015-08-07  7:59 ` [PATCH 12/31] drm/amdgpu: " Andrzej Hajda
                   ` (19 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-pm

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/cpufreq/sfi-cpufreq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/cpufreq/sfi-cpufreq.c b/drivers/cpufreq/sfi-cpufreq.c
index ffa3389..992ce6f 100644
--- a/drivers/cpufreq/sfi-cpufreq.c
+++ b/drivers/cpufreq/sfi-cpufreq.c
@@ -45,12 +45,10 @@ static int sfi_parse_freq(struct sfi_table_header *table)
 	pentry = (struct sfi_freq_table_entry *)sb->pentry;
 	totallen = num_freq_table_entries * sizeof(*pentry);
 
-	sfi_cpufreq_array = kzalloc(totallen, GFP_KERNEL);
+	sfi_cpufreq_array = kmemdup(pentry, totallen, GFP_KERNEL);
 	if (!sfi_cpufreq_array)
 		return -ENOMEM;
 
-	memcpy(sfi_cpufreq_array, pentry, totallen);
-
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 12/31] drm/amdgpu: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (10 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 11/31] cpufreq/sfi: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16  9:56   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 13/31] memstick: " Andrzej Hajda
                   ` (18 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, dri-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 8da6424..94bd992 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -549,12 +549,10 @@ int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata,
 	if (metadata == NULL)
 		return -EINVAL;
 
-	buffer = kzalloc(metadata_size, GFP_KERNEL);
+	buffer = kmemdup(metadata, metadata_size, GFP_KERNEL);
 	if (buffer == NULL)
 		return -ENOMEM;
 
-	memcpy(buffer, metadata, metadata_size);
-
 	kfree(bo->metadata);
 	bo->metadata_flags = flags;
 	bo->metadata = buffer;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 13/31] memstick: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (11 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 12/31] drm/amdgpu: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16  9:57   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 14/31] message/fusion: " Andrzej Hajda
                   ` (17 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Dan Carpenter, Andrew Morton
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/memstick/core/mspro_block.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 922a750..1f1dd9b 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -1033,12 +1033,11 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
 	}
 	msb->attr_group.name = "media_attributes";
 
-	buffer = kmalloc(attr_len, GFP_KERNEL);
+	buffer = kmemdup((char *)attr, attr_len, GFP_KERNEL);
 	if (!buffer) {
 		rc = -ENOMEM;
 		goto out_free_attr;
 	}
-	memcpy(buffer, (char *)attr, attr_len);
 
 	for (cnt = 0; cnt < attr_count; ++cnt) {
 		s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 14/31] message/fusion: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (12 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 13/31] memstick: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:01   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 15/31] misc/vmw_vmci: " Andrzej Hajda
                   ` (16 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Nagalakshmi Nandigama, Praveen Krishnamoorthy, Sreekanth Reddy,
	Abhijit Mahajan
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, MPT-FusionLinux.pdl, linux-scsi

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/message/fusion/mptbase.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5dcc031..1551f51 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -5971,13 +5971,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
 	if (mpt_config(ioc, &cfg) != 0)
 		goto out;
 
-	mem = kmalloc(iocpage2sz, GFP_KERNEL);
+	mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
 	if (!mem) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	memcpy(mem, (u8 *)pIoc2, iocpage2sz);
 	ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
 
 	mpt_read_ioc_pg_3(ioc);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 15/31] misc/vmw_vmci: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (13 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 14/31] message/fusion: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:01   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 16/31] net/cavium/liquidio: " Andrzej Hajda
                   ` (15 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/misc/vmw_vmci/vmci_datagram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
index 8226652..8a4b6bb 100644
--- a/drivers/misc/vmw_vmci/vmci_datagram.c
+++ b/drivers/misc/vmw_vmci/vmci_datagram.c
@@ -276,11 +276,10 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
 		}
 
 		/* We make a copy to enqueue. */
-		new_dg = kmalloc(dg_size, GFP_KERNEL);
+		new_dg = kmemdup(dg, dg_size, GFP_KERNEL);
 		if (new_dg == NULL)
 			return VMCI_ERROR_NO_MEM;
 
-		memcpy(new_dg, dg, dg_size);
 		retval = vmci_ctx_enqueue_datagram(dg->dst.context, new_dg);
 		if (retval < VMCI_SUCCESS) {
 			kfree(new_dg);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 16/31] net/cavium/liquidio: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (14 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 15/31] misc/vmw_vmci: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:02   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 17/31] scsi/aacraid: " Andrzej Hajda
                   ` (14 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	Sunil Goutham, Robert Richter
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, netdev, linux-arm-kernel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index f67641a..8e23e3f 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -602,12 +602,10 @@ int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
 	snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s",
 		 h->version);
 
-	buffer = kmalloc(size, GFP_KERNEL);
+	buffer = kmemdup(data, size, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
 
-	memcpy(buffer, data, size);
-
 	p = buffer + sizeof(struct octeon_firmware_file_header);
 
 	/* load all images */
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 17/31] scsi/aacraid: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (15 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 16/31] net/cavium/liquidio: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:02   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 18/31] scsi/aic7xxx: " Andrzej Hajda
                   ` (13 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions, James E.J. Bottomley
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-scsi

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/scsi/aacraid/commctrl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 54195a1..d2ed626 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 			}
 		} else {
 			struct user_sgmap* usg;
-			usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
-			  + sizeof(struct sgmap), GFP_KERNEL);
+			usg = kmemdup(upsg,
+				      actual_fibsize - sizeof(struct aac_srb) + sizeof(struct sgmap),
+				      GFP_KERNEL);
 			if (!usg) {
 				dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
 				rcode = -ENOMEM;
 				goto cleanup;
 			}
-			memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
-			  + sizeof(struct sgmap));
 			actual_fibsize = actual_fibsize64;
 
 			for (i = 0; i < usg->count; i++) {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 18/31] scsi/aic7xxx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (16 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 17/31] scsi/aacraid: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:02   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 19/31] staging/lustre: " Andrzej Hajda
                   ` (12 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, James E.J. Bottomley, linux-scsi

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++--
 drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 109e2c9..8592448 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -9494,10 +9494,10 @@ ahd_loadseq(struct ahd_softc *ahd)
 	if (cs_count != 0) {
 
 		cs_count *= sizeof(struct cs);
-		ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+		ahd->critical_sections = kmemdup(cs_table, cs_count,
+						 GFP_ATOMIC);
 		if (ahd->critical_sections == NULL)
 			panic("ahd_loadseq: Could not malloc");
-		memcpy(ahd->critical_sections, cs_table, cs_count);
 	}
 	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
 
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index c4829d8..3178730 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -6940,10 +6940,10 @@ ahc_loadseq(struct ahc_softc *ahc)
 	if (cs_count != 0) {
 
 		cs_count *= sizeof(struct cs);
-		ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+		ahc->critical_sections = kmemdup(cs_table, cs_count,
+						 GFP_ATOMIC);
 		if (ahc->critical_sections == NULL)
 			panic("ahc_loadseq: Could not malloc");
-		memcpy(ahc->critical_sections, cs_table, cs_count);
 	}
 	ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 19/31] staging/lustre: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (17 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 18/31] scsi/aic7xxx: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 20/31] fs/cifs: " Andrzej Hajda
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, HPDD-discuss, devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/staging/lustre/lustre/obdclass/acl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c
index bc3fc47..933456c 100644
--- a/drivers/staging/lustre/lustre/obdclass/acl.c
+++ b/drivers/staging/lustre/lustre/obdclass/acl.c
@@ -104,11 +104,10 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
 	if (unlikely(old_count <= new_count))
 		return old_size;
 
-	new = kzalloc(new_size, GFP_NOFS);
+	new = kmemdup(*header, new_size, GFP_NOFS);
 	if (unlikely(new == NULL))
 		return -ENOMEM;
 
-	memcpy(new, *header, new_size);
 	kfree(*header);
 	*header = new;
 	return new_size;
@@ -125,11 +124,10 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header,
 	if (unlikely(old_count <= ext_count))
 		return 0;
 
-	new = kzalloc(ext_size, GFP_NOFS);
+	new = kmemdup(*header, ext_size, GFP_NOFS);
 	if (unlikely(new == NULL))
 		return -ENOMEM;
 
-	memcpy(new, *header, ext_size);
 	kfree(*header);
 	*header = new;
 	return 0;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 20/31] fs/cifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (18 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 19/31] staging/lustre: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:03   ` Andrzej Hajda
  2015-09-17  5:00   ` Steve French
  2015-08-07  7:59 ` [PATCH 21/31] fs/dlm: " Andrzej Hajda
                   ` (10 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Steve French
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-cifs

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/cifs/smb2pdu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 070fb2a..2d6b72f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1394,14 +1394,13 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
 		goto ioctl_exit;
 	}
 
-	*out_data = kmalloc(*plen, GFP_KERNEL);
+	*out_data = kmemdup(rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
+			    *plen, GFP_KERNEL);
 	if (*out_data == NULL) {
 		rc = -ENOMEM;
 		goto ioctl_exit;
 	}
 
-	memcpy(*out_data, rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
-	       *plen);
 ioctl_exit:
 	free_rsp_buf(resp_buftype, rsp);
 	return rc;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 21/31] fs/dlm: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (19 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 20/31] fs/cifs: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:03   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 22/31] fs/ntfs: " Andrzej Hajda
                   ` (9 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Christine Caulfield, David Teigland
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, cluster-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/dlm/lowcomms.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 754fd6c..b31b32a 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1317,10 +1317,9 @@ static void init_local(void)
 		if (dlm_our_addr(&sas, i))
 			break;
 
-		addr = kmalloc(sizeof(*addr), GFP_NOFS);
+		addr = kmemdup(&sas, sizeof(*addr), GFP_NOFS);
 		if (!addr)
 			break;
-		memcpy(addr, &sas, sizeof(*addr));
 		dlm_local_addr[dlm_local_count++] = addr;
 	}
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (20 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 21/31] fs/dlm: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:04   ` Andrzej Hajda
  2015-09-23 10:21   ` Anton Altaparmakov
  2015-08-07  7:59 ` [PATCH 23/31] fs/ocfs2: " Andrzej Hajda
                   ` (8 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Anton Altaparmakov
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-ntfs-dev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/ntfs/dir.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 9e38daf..2b7fef0 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
 	 * map the mft record without deadlocking.
 	 */
 	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
-	ir = kmalloc(rc, GFP_NOFS);
+	/* Copy the index root value (it has been verified in read_inode). */
+	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
+		     rc, GFP_NOFS);
 	if (unlikely(!ir)) {
 		err = -ENOMEM;
 		goto err_out;
 	}
-	/* Copy the index root value (it has been verified in read_inode). */
-	memcpy(ir, (u8*)ctx->attr +
-			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
 	ntfs_attr_put_search_ctx(ctx);
 	unmap_mft_record(ndir);
 	ctx = NULL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 23/31] fs/ocfs2: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (21 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 22/31] fs/ntfs: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:04   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 24/31] fs/omfs: " Andrzej Hajda
                   ` (7 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, ocfs2-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/ocfs2/localalloc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 0a4457f..194d6d6 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -434,12 +434,11 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
 	bh = osb->local_alloc_bh;
 	alloc = (struct ocfs2_dinode *) bh->b_data;
 
-	alloc_copy = kmalloc(bh->b_size, GFP_NOFS);
+	alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS);
 	if (!alloc_copy) {
 		status = -ENOMEM;
 		goto out_commit;
 	}
-	memcpy(alloc_copy, alloc, bh->b_size);
 
 	status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode),
 					 bh, OCFS2_JOURNAL_ACCESS_WRITE);
@@ -1285,13 +1284,12 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
 	 * local alloc shutdown won't try to double free main bitmap
 	 * bits. Make a copy so the sync function knows which bits to
 	 * free. */
-	alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_NOFS);
+	alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS);
 	if (!alloc_copy) {
 		status = -ENOMEM;
 		mlog_errno(status);
 		goto bail;
 	}
-	memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
 
 	status = ocfs2_journal_access_di(handle,
 					 INODE_CACHE(local_alloc_inode),
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 24/31] fs/omfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (22 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 23/31] fs/ocfs2: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 12:22   ` Bob Copeland
  2015-09-16 10:05   ` Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 25/31] fs/ubifs: " Andrzej Hajda
                   ` (6 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Bob Copeland
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-karma-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/omfs/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 3d935c8..02af1a3 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -333,12 +333,11 @@ static int omfs_get_imap(struct super_block *sb)
 		bh = sb_bread(sb, block++);
 		if (!bh)
 			goto nomem_free;
-		*ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
+		*ptr = kmemdup(bh->b_data, sb->s_blocksize, GFP_KERNEL);
 		if (!*ptr) {
 			brelse(bh);
 			goto nomem_free;
 		}
-		memcpy(*ptr, bh->b_data, sb->s_blocksize);
 		if (count < sb->s_blocksize)
 			memset((void *)*ptr + count, 0xff,
 				sb->s_blocksize - count);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 25/31] fs/ubifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (23 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 24/31] fs/omfs: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-08  9:12   ` Richard Weinberger
  2015-08-10  8:16   ` Artem Bityutskiy
  2015-08-07  7:59 ` [PATCH 26/31] net/sched: " Andrzej Hajda
                   ` (5 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Artem Bityutskiy, Adrian Hunter
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-mtd

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 fs/ubifs/lpt.c | 6 ++----
 fs/ubifs/tnc.c | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index dc9f27e..9a51710 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -1498,11 +1498,10 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c,
 	}
 
 	/* nnode is being committed, so copy it */
-	n = kmalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
+	n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS);
 	if (unlikely(!n))
 		return ERR_PTR(-ENOMEM);
 
-	memcpy(n, nnode, sizeof(struct ubifs_nnode));
 	n->cnext = NULL;
 	__set_bit(DIRTY_CNODE, &n->flags);
 	__clear_bit(COW_CNODE, &n->flags);
@@ -1549,11 +1548,10 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c,
 	}
 
 	/* pnode is being committed, so copy it */
-	p = kmalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
+	p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS);
 	if (unlikely(!p))
 		return ERR_PTR(-ENOMEM);
 
-	memcpy(p, pnode, sizeof(struct ubifs_pnode));
 	p->cnext = NULL;
 	__set_bit(DIRTY_CNODE, &p->flags);
 	__clear_bit(COW_CNODE, &p->flags);
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
index 957f575..fa9a20c 100644
--- a/fs/ubifs/tnc.c
+++ b/fs/ubifs/tnc.c
@@ -198,11 +198,10 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c,
 {
 	struct ubifs_znode *zn;
 
-	zn = kmalloc(c->max_znode_sz, GFP_NOFS);
+	zn = kmemdup(znode, c->max_znode_sz, GFP_NOFS);
 	if (unlikely(!zn))
 		return ERR_PTR(-ENOMEM);
 
-	memcpy(zn, znode, c->max_znode_sz);
 	zn->cnext = NULL;
 	__set_bit(DIRTY_ZNODE, &zn->flags);
 	__clear_bit(COW_ZNODE, &zn->flags);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 26/31] net/sched: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (24 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 25/31] fs/ubifs: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 10:35   ` Daniel Borkmann
  2015-08-07  7:59 ` [PATCH 27/31] net/tipc: " Andrzej Hajda
                   ` (4 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Jamal Hadi Salim, David S. Miller
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, netdev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 net/sched/act_bpf.c | 4 +---
 net/sched/cls_bpf.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c
index 1b97dab..5c0fa03 100644
--- a/net/sched/act_bpf.c
+++ b/net/sched/act_bpf.c
@@ -190,12 +190,10 @@ static int tcf_bpf_init_from_ops(struct nlattr **tb, struct tcf_bpf_cfg *cfg)
 	if (bpf_size != nla_len(tb[TCA_ACT_BPF_OPS]))
 		return -EINVAL;
 
-	bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
+	bpf_ops = kmemdup(nla_data(tb[TCA_ACT_BPF_OPS]), bpf_size, GFP_KERNEL);
 	if (bpf_ops == NULL)
 		return -ENOMEM;
 
-	memcpy(bpf_ops, nla_data(tb[TCA_ACT_BPF_OPS]), bpf_size);
-
 	fprog_tmp.len = bpf_num_ops;
 	fprog_tmp.filter = bpf_ops;
 
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index e5168f8..423f774 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,12 +212,10 @@ static int cls_bpf_prog_from_ops(struct nlattr **tb,
 	if (bpf_size != nla_len(tb[TCA_BPF_OPS]))
 		return -EINVAL;
 
-	bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
+	bpf_ops = kmemdup(nla_data(tb[TCA_BPF_OPS]), bpf_size, GFP_KERNEL);
 	if (bpf_ops == NULL)
 		return -ENOMEM;
 
-	memcpy(bpf_ops, nla_data(tb[TCA_BPF_OPS]), bpf_size);
-
 	fprog_tmp.len = bpf_num_ops;
 	fprog_tmp.filter = bpf_ops;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 27/31] net/tipc: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (25 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 26/31] net/sched: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-09-16 10:07   ` Andrzej Hajda
  2015-09-17  1:19   ` Ying Xue
  2015-08-07  7:59 ` [PATCH 28/31] net/xfrm: " Andrzej Hajda
                   ` (3 subsequent siblings)
  30 siblings, 2 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, David S. Miller, netdev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 net/tipc/server.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/tipc/server.c b/net/tipc/server.c
index 922e04a..c187cad 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -411,13 +411,12 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
 	if (!entry)
 		return NULL;
 
-	buf = kmalloc(len, GFP_ATOMIC);
+	buf = kmemdup(data, len, GFP_ATOMIC);
 	if (!buf) {
 		kfree(entry);
 		return NULL;
 	}
 
-	memcpy(buf, data, len);
 	entry->iov.iov_base = buf;
 	entry->iov.iov_len = len;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 28/31] net/xfrm: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (26 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 27/31] net/tipc: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-12 10:25   ` Steffen Klassert
  2015-08-07  7:59 ` [PATCH 29/31] sound/oxfw: " Andrzej Hajda
                   ` (2 subsequent siblings)
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, netdev

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 net/xfrm/xfrm_user.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 0cebf1f..a8de9e3 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -925,12 +925,10 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
 			return err;
 
 		if (attrs[XFRMA_ADDRESS_FILTER]) {
-			filter = kmalloc(sizeof(*filter), GFP_KERNEL);
+			filter = kmemdup(nla_data(attrs[XFRMA_ADDRESS_FILTER]),
+					 sizeof(*filter), GFP_KERNEL);
 			if (filter == NULL)
 				return -ENOMEM;
-
-			memcpy(filter, nla_data(attrs[XFRMA_ADDRESS_FILTER]),
-			       sizeof(*filter));
 		}
 
 		if (attrs[XFRMA_PROTO])
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 29/31] sound/oxfw: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (27 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 28/31] net/xfrm: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 12:52   ` [alsa-devel] " Takashi Iwai
  2015-08-07  7:59 ` [PATCH 30/31] sound/atom: " Andrzej Hajda
  2015-08-07  7:59 ` [PATCH 31/31] sound/soc: " Andrzej Hajda
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Clemens Ladisch, Jaroslav Kysela
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, alsa-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 sound/firewire/oxfw/oxfw-stream.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
index 873d40f..77ad5b9 100644
--- a/sound/firewire/oxfw/oxfw-stream.c
+++ b/sound/firewire/oxfw/oxfw-stream.c
@@ -512,12 +512,11 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
 	if (err < 0)
 		goto end;
 
-	formats[eid] = kmalloc(*len, GFP_KERNEL);
+	formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
 	if (formats[eid] == NULL) {
 		err = -ENOMEM;
 		goto end;
 	}
-	memcpy(formats[eid], buf, *len);
 
 	/* apply the format for each available sampling rate */
 	for (i = 0; i < ARRAY_SIZE(oxfw_rate_table); i++) {
@@ -531,12 +530,11 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
 			continue;
 
 		eid++;
-		formats[eid] = kmalloc(*len, GFP_KERNEL);
+		formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
 		if (formats[eid] == NULL) {
 			err = -ENOMEM;
 			goto end;
 		}
-		memcpy(formats[eid], buf, *len);
 		formats[eid][2] = avc_stream_rate_table[i];
 	}
 
@@ -594,12 +592,11 @@ static int fill_stream_formats(struct snd_oxfw *oxfw,
 		if (err < 0)
 			break;
 
-		formats[eid] = kmalloc(len, GFP_KERNEL);
+		formats[eid] = kmemdup(buf, len, GFP_KERNEL);
 		if (formats[eid] == NULL) {
 			err = -ENOMEM;
 			break;
 		}
-		memcpy(formats[eid], buf, len);
 
 		/* get next entry */
 		len = AVC_GENERIC_FRAME_MAXIMUM_BYTES;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 30/31] sound/atom: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (28 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 29/31] sound/oxfw: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  2015-08-07 12:29   ` Mark Brown
  2015-08-07  7:59 ` [PATCH 31/31] sound/soc: " Andrzej Hajda
  30 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, Jaroslav Kysela, Takashi Iwai, alsa-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 sound/soc/intel/atom/sst/sst_ipc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst_ipc.c b/sound/soc/intel/atom/sst/sst_ipc.c
index 5a27861..3dc7358 100644
--- a/sound/soc/intel/atom/sst/sst_ipc.c
+++ b/sound/soc/intel/atom/sst/sst_ipc.c
@@ -352,10 +352,9 @@ void sst_process_reply_mrfld(struct intel_sst_drv *sst_drv_ctx,
 	 * copy from mailbox
 	 **/
 	if (msg_high.part.large) {
-		data = kzalloc(msg_low, GFP_KERNEL);
+		data = kmemdup((void *)msg->mailbox_data, msg_low, GFP_KERNEL);
 		if (!data)
 			return;
-		memcpy(data, (void *) msg->mailbox_data, msg_low);
 		/* Copy command id so that we can use to put sst to reset */
 		dsp_hdr = (struct ipc_dsp_hdr *)data;
 		cmd_id = dsp_hdr->cmd_id;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* [PATCH 31/31] sound/soc: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
                   ` (29 preceding siblings ...)
  2015-08-07  7:59 ` [PATCH 30/31] sound/atom: " Andrzej Hajda
@ 2015-08-07  7:59 ` Andrzej Hajda
  30 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-08-07  7:59 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, alsa-devel

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 sound/soc/soc-topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 4dadb5e..a5da91b 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -831,12 +831,12 @@ static int soc_tplg_denum_create_values(struct soc_enum *se,
 	if (ec->items > sizeof(*ec->values))
 		return -EINVAL;
 
-	se->dobj.control.dvalues =
-		kmalloc(ec->items * sizeof(u32), GFP_KERNEL);
+	se->dobj.control.dvalues = kmemdup(ec->values,
+					   ec->items * sizeof(u32),
+					   GFP_KERNEL);
 	if (!se->dobj.control.dvalues)
 		return -ENOMEM;
 
-	memcpy(se->dobj.control.dvalues, ec->values, ec->items * sizeof(u32));
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 76+ messages in thread

* Re: [PATCH 09/31] crypto: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 09/31] crypto: use " Andrzej Hajda
@ 2015-08-07  8:05   ` Herbert Xu
  0 siblings, 0 replies; 76+ messages in thread
From: Herbert Xu @ 2015-08-07  8:05 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: David S. Miller, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-crypto

On Fri, Aug 07, 2015 at 09:59:15AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Actually I think you've identified a bug in the code.
 
> diff --git a/crypto/echainiv.c b/crypto/echainiv.c
> index d3896c7..d8968c0 100644
> --- a/crypto/echainiv.c
> +++ b/crypto/echainiv.c
> @@ -134,13 +134,10 @@ static int echainiv_encrypt(struct aead_request *req)
>  
>  	if (unlikely(!IS_ALIGNED((unsigned long)info,
>  				 crypto_aead_alignmask(geniv) + 1))) {
> -		info = kmalloc(ivsize, req->base.flags &
> -				       CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL:
> -								  GFP_ATOMIC);
> +		info = kmemdup(req->iv, ivsize,
> +			       req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC);
>  		if (!info)
>  			return -ENOMEM;
> -
> -		memcpy(info, req->iv, ivsize);

This is meant to reallocate a buffer aligned to geniv but it isn't
actually doing that.

So we should be changing it to align the pointer rather than
converting it to memcpy.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 11/31] cpufreq/sfi: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 11/31] cpufreq/sfi: " Andrzej Hajda
@ 2015-08-07  8:58   ` Viresh Kumar
  0 siblings, 0 replies; 76+ messages in thread
From: Viresh Kumar @ 2015-08-07  8:58 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Rafael J. Wysocki, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-pm

On 07-08-15, 09:59, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/cpufreq/sfi-cpufreq.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/cpufreq/sfi-cpufreq.c b/drivers/cpufreq/sfi-cpufreq.c
> index ffa3389..992ce6f 100644
> --- a/drivers/cpufreq/sfi-cpufreq.c
> +++ b/drivers/cpufreq/sfi-cpufreq.c
> @@ -45,12 +45,10 @@ static int sfi_parse_freq(struct sfi_table_header *table)
>  	pentry = (struct sfi_freq_table_entry *)sb->pentry;
>  	totallen = num_freq_table_entries * sizeof(*pentry);
>  
> -	sfi_cpufreq_array = kzalloc(totallen, GFP_KERNEL);
> +	sfi_cpufreq_array = kmemdup(pentry, totallen, GFP_KERNEL);
>  	if (!sfi_cpufreq_array)
>  		return -ENOMEM;
>  
> -	memcpy(sfi_cpufreq_array, pentry, totallen);
> -

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 03/31] arch/m68k/bootinfo: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 03/31] arch/m68k/bootinfo: " Andrzej Hajda
@ 2015-08-07 10:23   ` Geert Uytterhoeven
  0 siblings, 0 replies; 76+ messages in thread
From: Geert Uytterhoeven @ 2015-08-07 10:23 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, linux-m68k

On Fri, Aug 7, 2015 at 9:59 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Thanks, will apply and queue for v4.3.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 26/31] net/sched: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 26/31] net/sched: " Andrzej Hajda
@ 2015-08-07 10:35   ` Daniel Borkmann
  0 siblings, 0 replies; 76+ messages in thread
From: Daniel Borkmann @ 2015-08-07 10:35 UTC (permalink / raw)
  To: Andrzej Hajda, Jamal Hadi Salim, David S. Miller
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, netdev

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Not sure where the rest of this series went, but if you want this patch
to be routed via net-next tree (which I recommend, to avoid cross tree
conflicts), then you would need to send these patches separately, rebased
to that tree, and also mention [PATCH net-next XX/YY] in the subject.
                                       ^^^^^^^^
Thanks,
Daniel

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 24/31] fs/omfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 24/31] fs/omfs: " Andrzej Hajda
@ 2015-08-07 12:22   ` Bob Copeland
  2015-09-16 10:05   ` Andrzej Hajda
  1 sibling, 0 replies; 76+ messages in thread
From: Bob Copeland @ 2015-08-07 12:22 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-karma-devel

On Fri, Aug 07, 2015 at 09:59:30AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Thanks -

Acked-by: Bob Copeland <me@bobcopeland.com>

-- 
Bob Copeland %% http://bobcopeland.com/

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 30/31] sound/atom: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 30/31] sound/atom: " Andrzej Hajda
@ 2015-08-07 12:29   ` Mark Brown
  0 siblings, 0 replies; 76+ messages in thread
From: Mark Brown @ 2015-08-07 12:29 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Liam Girdwood, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, Jaroslav Kysela, Takashi Iwai, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

On Fri, Aug 07, 2015 at 09:59:36AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 

Applied, but please make an effort to use subject lines reflecting the
style for the subsysetem and if you're sending a patch series make sure
that at least the cover letter goes to everyone or (if there are no
interdependencies as is the case here) just send them individually.
That way people can tell what's going on in terms of dependencies.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [alsa-devel] [PATCH 29/31] sound/oxfw: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 29/31] sound/oxfw: " Andrzej Hajda
@ 2015-08-07 12:52   ` Takashi Iwai
  0 siblings, 0 replies; 76+ messages in thread
From: Takashi Iwai @ 2015-08-07 12:52 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Clemens Ladisch, Jaroslav Kysela, alsa-devel, Marek Szyprowski,
	linux-kernel, Bartlomiej Zolnierkiewicz

On Fri, 07 Aug 2015 09:59:35 +0200,
Andrzej Hajda wrote:
> 
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Applied, thanks.


Takashi

> ---
>  sound/firewire/oxfw/oxfw-stream.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
> index 873d40f..77ad5b9 100644
> --- a/sound/firewire/oxfw/oxfw-stream.c
> +++ b/sound/firewire/oxfw/oxfw-stream.c
> @@ -512,12 +512,11 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
>  	if (err < 0)
>  		goto end;
>  
> -	formats[eid] = kmalloc(*len, GFP_KERNEL);
> +	formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
>  	if (formats[eid] == NULL) {
>  		err = -ENOMEM;
>  		goto end;
>  	}
> -	memcpy(formats[eid], buf, *len);
>  
>  	/* apply the format for each available sampling rate */
>  	for (i = 0; i < ARRAY_SIZE(oxfw_rate_table); i++) {
> @@ -531,12 +530,11 @@ assume_stream_formats(struct snd_oxfw *oxfw, enum avc_general_plug_dir dir,
>  			continue;
>  
>  		eid++;
> -		formats[eid] = kmalloc(*len, GFP_KERNEL);
> +		formats[eid] = kmemdup(buf, *len, GFP_KERNEL);
>  		if (formats[eid] == NULL) {
>  			err = -ENOMEM;
>  			goto end;
>  		}
> -		memcpy(formats[eid], buf, *len);
>  		formats[eid][2] = avc_stream_rate_table[i];
>  	}
>  
> @@ -594,12 +592,11 @@ static int fill_stream_formats(struct snd_oxfw *oxfw,
>  		if (err < 0)
>  			break;
>  
> -		formats[eid] = kmalloc(len, GFP_KERNEL);
> +		formats[eid] = kmemdup(buf, len, GFP_KERNEL);
>  		if (formats[eid] == NULL) {
>  			err = -ENOMEM;
>  			break;
>  		}
> -		memcpy(formats[eid], buf, len);
>  
>  		/* get next entry */
>  		len = AVC_GENERIC_FRAME_MAXIMUM_BYTES;
> -- 
> 1.9.1
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 07/31] arch/x86/microcode: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 07/31] arch/x86/microcode: " Andrzej Hajda
@ 2015-08-07 16:30   ` Borislav Petkov
  0 siblings, 0 replies; 76+ messages in thread
From: Borislav Petkov @ 2015-08-07 16:30 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, x86

On Fri, Aug 07, 2015 at 09:59:13AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

I dropped this footnote from the commit message as it seems that your
fix is going to be integrated into memdup.cocci.

> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  arch/x86/kernel/cpu/microcode/amd.c         | 4 +---
>  arch/x86/kernel/cpu/microcode/intel_early.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)

Applied, thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 05/31] arch/powerpc/nvram: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 05/31] arch/powerpc/nvram: " Andrzej Hajda
@ 2015-08-07 19:46   ` Nathan Fontenot
  2015-08-19 23:14   ` [05/31] " Michael Ellerman
  1 sibling, 0 replies; 76+ messages in thread
From: Nathan Fontenot @ 2015-08-07 19:46 UTC (permalink / raw)
  To: Andrzej Hajda, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Marek Szyprowski, linuxppc-dev, linux-kernel, Bartlomiej Zolnierkiewicz

On 08/07/2015 02:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 06/31] arch/powerpc/pseries: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 06/31] arch/powerpc/pseries: " Andrzej Hajda
@ 2015-08-07 19:46   ` Nathan Fontenot
  2015-08-19 23:14   ` [06/31] " Michael Ellerman
  1 sibling, 0 replies; 76+ messages in thread
From: Nathan Fontenot @ 2015-08-07 19:46 UTC (permalink / raw)
  To: Andrzej Hajda, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Marek Szyprowski, linuxppc-dev, linux-kernel, Bartlomiej Zolnierkiewicz

On 08/07/2015 02:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 10/31] clk/mmp: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 10/31] clk/mmp: " Andrzej Hajda
@ 2015-08-07 22:17   ` Stephen Boyd
  0 siblings, 0 replies; 76+ messages in thread
From: Stephen Boyd @ 2015-08-07 22:17 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Michael Turquette, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	linux-kernel, linux-clk

On 08/07, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 25/31] fs/ubifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 25/31] fs/ubifs: " Andrzej Hajda
@ 2015-08-08  9:12   ` Richard Weinberger
  2015-08-10  8:16   ` Artem Bityutskiy
  1 sibling, 0 replies; 76+ messages in thread
From: Richard Weinberger @ 2015-08-08  9:12 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Artem Bityutskiy, Adrian Hunter, Marek Szyprowski, linux-mtd,
	LKML, Bartlomiej Zolnierkiewicz

On Fri, Aug 7, 2015 at 9:59 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/ubifs/lpt.c | 6 ++----
>  fs/ubifs/tnc.c | 3 +--
>  2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
> index dc9f27e..9a51710 100644
> --- a/fs/ubifs/lpt.c
> +++ b/fs/ubifs/lpt.c
> @@ -1498,11 +1498,10 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c,
>         }
>
>         /* nnode is being committed, so copy it */
> -       n = kmalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
> +       n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS);
>         if (unlikely(!n))
>                 return ERR_PTR(-ENOMEM);
>
> -       memcpy(n, nnode, sizeof(struct ubifs_nnode));
>         n->cnext = NULL;
>         __set_bit(DIRTY_CNODE, &n->flags);
>         __clear_bit(COW_CNODE, &n->flags);
> @@ -1549,11 +1548,10 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c,
>         }
>
>         /* pnode is being committed, so copy it */
> -       p = kmalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
> +       p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS);
>         if (unlikely(!p))
>                 return ERR_PTR(-ENOMEM);
>
> -       memcpy(p, pnode, sizeof(struct ubifs_pnode));
>         p->cnext = NULL;
>         __set_bit(DIRTY_CNODE, &p->flags);
>         __clear_bit(COW_CNODE, &p->flags);
> diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c
> index 957f575..fa9a20c 100644
> --- a/fs/ubifs/tnc.c
> +++ b/fs/ubifs/tnc.c
> @@ -198,11 +198,10 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c,
>  {
>         struct ubifs_znode *zn;
>
> -       zn = kmalloc(c->max_znode_sz, GFP_NOFS);
> +       zn = kmemdup(znode, c->max_znode_sz, GFP_NOFS);
>         if (unlikely(!zn))
>                 return ERR_PTR(-ENOMEM);
>
> -       memcpy(zn, znode, c->max_znode_sz);
>         zn->cnext = NULL;
>         __set_bit(DIRTY_ZNODE, &zn->flags);
>         __clear_bit(COW_ZNODE, &zn->flags);

Reviewed-by: Richard Weinberger <richard@nod.at>

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 04/31] arch/mips/bcm47xx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 04/31] arch/mips/bcm47xx: " Andrzej Hajda
@ 2015-08-09 20:14   ` Hauke Mehrtens
  0 siblings, 0 replies; 76+ messages in thread
From: Hauke Mehrtens @ 2015-08-09 20:14 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Andrzej Hajda, Rafał Miłecki,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-mips

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 25/31] fs/ubifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 25/31] fs/ubifs: " Andrzej Hajda
  2015-08-08  9:12   ` Richard Weinberger
@ 2015-08-10  8:16   ` Artem Bityutskiy
  1 sibling, 0 replies; 76+ messages in thread
From: Artem Bityutskiy @ 2015-08-10  8:16 UTC (permalink / raw)
  To: Andrzej Hajda, Adrian Hunter
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, linux-mtd

On Fri, 2015-08-07 at 09:59 +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Picked to 'linux-ubifs.git', thanks!

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 28/31] net/xfrm: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 28/31] net/xfrm: " Andrzej Hajda
@ 2015-08-12 10:25   ` Steffen Klassert
  0 siblings, 0 replies; 76+ messages in thread
From: Steffen Klassert @ 2015-08-12 10:25 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Herbert Xu, David S. Miller, Bartlomiej Zolnierkiewicz,
	Marek Szyprowski, linux-kernel, netdev

On Fri, Aug 07, 2015 at 09:59:34AM +0200, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Applied to ipsec-next, thanks!

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [06/31] arch/powerpc/pseries: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 06/31] arch/powerpc/pseries: " Andrzej Hajda
  2015-08-07 19:46   ` Nathan Fontenot
@ 2015-08-19 23:14   ` Michael Ellerman
  1 sibling, 0 replies; 76+ messages in thread
From: Michael Ellerman @ 2015-08-19 23:14 UTC (permalink / raw)
  To: Andrzej Hajda, Benjamin Herrenschmidt, Paul Mackerras
  Cc: Andrzej Hajda, Marek Szyprowski, linuxppc-dev, linux-kernel,
	Bartlomiej Zolnierkiewicz

On Fri, 2015-07-08 at 07:59:12 UTC, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2e16acc5ee3626bcd32e

cheers

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [05/31] arch/powerpc/nvram: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 05/31] arch/powerpc/nvram: " Andrzej Hajda
  2015-08-07 19:46   ` Nathan Fontenot
@ 2015-08-19 23:14   ` Michael Ellerman
  1 sibling, 0 replies; 76+ messages in thread
From: Michael Ellerman @ 2015-08-19 23:14 UTC (permalink / raw)
  To: Andrzej Hajda, Benjamin Herrenschmidt, Paul Mackerras
  Cc: Andrzej Hajda, Marek Szyprowski, linuxppc-dev, linux-kernel,
	Bartlomiej Zolnierkiewicz

On Fri, 2015-07-08 at 07:59:11 UTC, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/fc9e9cbf4e48f28525ed

cheers

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 01/31] arch/arm/mach-lpc32xx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 01/31] arch/arm/mach-lpc32xx: " Andrzej Hajda
@ 2015-09-16  9:52   ` Andrzej Hajda
  2015-09-16 10:06     ` Arnd Bergmann
  0 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16  9:52 UTC (permalink / raw)
  To: Roland Stigge
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-arm-kernel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  arch/arm/mach-lpc32xx/pm.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
> index 207e812..dd3a432 100644
> --- a/arch/arm/mach-lpc32xx/pm.c
> +++ b/arch/arm/mach-lpc32xx/pm.c
> @@ -87,7 +87,8 @@ static int lpc32xx_pm_enter(suspend_state_t state)
>  	void *iram_swap_area;
>  
>  	/* Allocate some space for temporary IRAM storage */
> -	iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
> +	iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA,
> +				 lpc32xx_sys_suspend_sz, GFP_KERNEL);
>  	if (!iram_swap_area) {
>  		printk(KERN_ERR
>  		       "PM Suspend: cannot allocate memory to save portion "
> @@ -95,10 +96,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
>  		return -ENOMEM;
>  	}
>  
> -	/* Backup a small area of IRAM used for the suspend code */
> -	memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
> -		lpc32xx_sys_suspend_sz);
> -
>  	/*
>  	 * Copy code to suspend system into IRAM. The suspend code
>  	 * needs to run from IRAM as DRAM may no longer be available


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 02/31] arch/ia64/tioce: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 02/31] arch/ia64/tioce: " Andrzej Hajda
@ 2015-09-16  9:53   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16  9:53 UTC (permalink / raw)
  To: Tony Luck, Fenghua Yu
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, linux-ia64

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  arch/ia64/sn/pci/tioce_provider.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
> index 46d3df4..2f13276 100644
> --- a/arch/ia64/sn/pci/tioce_provider.c
> +++ b/arch/ia64/sn/pci/tioce_provider.c
> @@ -1000,11 +1000,11 @@ tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
>  	 * Allocate kernel bus soft and copy from prom.
>  	 */
>  
> -	tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL);
> +	tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common),
> +			       GFP_KERNEL);
>  	if (!tioce_common)
>  		return NULL;
>  
> -	memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common));
>  	tioce_common->ce_pcibus.bs_base = (unsigned long)
>  		ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base),
>  			sizeof(struct tioce_common));


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 08/31] arch/x86/intel-mid: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 08/31] arch/x86/intel-mid: " Andrzej Hajda
@ 2015-09-16  9:54   ` Andrzej Hajda
  2015-09-17 21:42   ` [tip:x86/platform] arch/x86/intel-mid: Use " tip-bot for Andrzej Hajda
  1 sibling, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16  9:54 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, x86

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  arch/x86/platform/intel-mid/sfi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
> index ce992e8..5ee360a 100644
> --- a/arch/x86/platform/intel-mid/sfi.c
> +++ b/arch/x86/platform/intel-mid/sfi.c
> @@ -197,10 +197,9 @@ static int __init sfi_parse_gpio(struct sfi_table_header *table)
>  	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
>  	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
>  
> -	gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL);
> +	gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL);
>  	if (!gpio_table)
>  		return -1;
> -	memcpy(gpio_table, pentry, num * sizeof(*pentry));
>  	gpio_num_entry = num;
>  
>  	pr_debug("GPIO pin info:\n");


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 12/31] drm/amdgpu: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 12/31] drm/amdgpu: " Andrzej Hajda
@ 2015-09-16  9:56   ` Andrzej Hajda
  2015-09-16 16:21     ` Christian König
  0 siblings, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16  9:56 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, dri-devel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 8da6424..94bd992 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -549,12 +549,10 @@ int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata,
>  	if (metadata == NULL)
>  		return -EINVAL;
>  
> -	buffer = kzalloc(metadata_size, GFP_KERNEL);
> +	buffer = kmemdup(metadata, metadata_size, GFP_KERNEL);
>  	if (buffer == NULL)
>  		return -ENOMEM;
>  
> -	memcpy(buffer, metadata, metadata_size);
> -
>  	kfree(bo->metadata);
>  	bo->metadata_flags = flags;
>  	bo->metadata = buffer;


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 13/31] memstick: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 13/31] memstick: " Andrzej Hajda
@ 2015-09-16  9:57   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16  9:57 UTC (permalink / raw)
  To: Dan Carpenter, Andrew Morton
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel

Ping.

Regards
Andrzej


On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/memstick/core/mspro_block.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
> index 922a750..1f1dd9b 100644
> --- a/drivers/memstick/core/mspro_block.c
> +++ b/drivers/memstick/core/mspro_block.c
> @@ -1033,12 +1033,11 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
>  	}
>  	msb->attr_group.name = "media_attributes";
>  
> -	buffer = kmalloc(attr_len, GFP_KERNEL);
> +	buffer = kmemdup((char *)attr, attr_len, GFP_KERNEL);
>  	if (!buffer) {
>  		rc = -ENOMEM;
>  		goto out_free_attr;
>  	}
> -	memcpy(buffer, (char *)attr, attr_len);
>  
>  	for (cnt = 0; cnt < attr_count; ++cnt) {
>  		s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 14/31] message/fusion: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 14/31] message/fusion: " Andrzej Hajda
@ 2015-09-16 10:01   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:01 UTC (permalink / raw)
  To: Sreekanth Reddy
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	MPT-FusionLinux.pdl, linux-scsi

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/message/fusion/mptbase.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index 5dcc031..1551f51 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -5971,13 +5971,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
>  	if (mpt_config(ioc, &cfg) != 0)
>  		goto out;
>  
> -	mem = kmalloc(iocpage2sz, GFP_KERNEL);
> +	mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
>  	if (!mem) {
>  		rc = -ENOMEM;
>  		goto out;
>  	}
>  
> -	memcpy(mem, (u8 *)pIoc2, iocpage2sz);
>  	ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
>  
>  	mpt_read_ioc_pg_3(ioc);


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 15/31] misc/vmw_vmci: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 15/31] misc/vmw_vmci: " Andrzej Hajda
@ 2015-09-16 10:01   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Dan Carpenter
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/misc/vmw_vmci/vmci_datagram.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
> index 8226652..8a4b6bb 100644
> --- a/drivers/misc/vmw_vmci/vmci_datagram.c
> +++ b/drivers/misc/vmw_vmci/vmci_datagram.c
> @@ -276,11 +276,10 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
>  		}
>  
>  		/* We make a copy to enqueue. */
> -		new_dg = kmalloc(dg_size, GFP_KERNEL);
> +		new_dg = kmemdup(dg, dg_size, GFP_KERNEL);
>  		if (new_dg == NULL)
>  			return VMCI_ERROR_NO_MEM;
>  
> -		memcpy(new_dg, dg, dg_size);
>  		retval = vmci_ctx_enqueue_datagram(dg->dst.context, new_dg);
>  		if (retval < VMCI_SUCCESS) {
>  			kfree(new_dg);


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 16/31] net/cavium/liquidio: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 16/31] net/cavium/liquidio: " Andrzej Hajda
@ 2015-09-16 10:02   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:02 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	Sunil Goutham, Robert Richter
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	netdev, linux-arm-kernel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/net/ethernet/cavium/liquidio/octeon_device.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> index f67641a..8e23e3f 100644
> --- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> @@ -602,12 +602,10 @@ int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
>  	snprintf(oct->fw_info.liquidio_firmware_version, 32, "LIQUIDIO: %s",
>  		 h->version);
>  
> -	buffer = kmalloc(size, GFP_KERNEL);
> +	buffer = kmemdup(data, size, GFP_KERNEL);
>  	if (!buffer)
>  		return -ENOMEM;
>  
> -	memcpy(buffer, data, size);
> -
>  	p = buffer + sizeof(struct octeon_firmware_file_header);
>  
>  	/* load all images */


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 17/31] scsi/aacraid: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 17/31] scsi/aacraid: " Andrzej Hajda
@ 2015-09-16 10:02   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:02 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions, James E.J. Bottomley
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, linux-scsi

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/scsi/aacraid/commctrl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
> index 54195a1..d2ed626 100644
> --- a/drivers/scsi/aacraid/commctrl.c
> +++ b/drivers/scsi/aacraid/commctrl.c
> @@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
>  			}
>  		} else {
>  			struct user_sgmap* usg;
> -			usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
> -			  + sizeof(struct sgmap), GFP_KERNEL);
> +			usg = kmemdup(upsg,
> +				      actual_fibsize - sizeof(struct aac_srb) + sizeof(struct sgmap),
> +				      GFP_KERNEL);
>  			if (!usg) {
>  				dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
>  				rcode = -ENOMEM;
>  				goto cleanup;
>  			}
> -			memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
> -			  + sizeof(struct sgmap));
>  			actual_fibsize = actual_fibsize64;
>  
>  			for (i = 0; i < usg->count; i++) {


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 18/31] scsi/aic7xxx: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 18/31] scsi/aic7xxx: " Andrzej Hajda
@ 2015-09-16 10:02   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:02 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	James E.J. Bottomley, linux-scsi

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++--
>  drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
> index 109e2c9..8592448 100644
> --- a/drivers/scsi/aic7xxx/aic79xx_core.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_core.c
> @@ -9494,10 +9494,10 @@ ahd_loadseq(struct ahd_softc *ahd)
>  	if (cs_count != 0) {
>  
>  		cs_count *= sizeof(struct cs);
> -		ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
> +		ahd->critical_sections = kmemdup(cs_table, cs_count,
> +						 GFP_ATOMIC);
>  		if (ahd->critical_sections == NULL)
>  			panic("ahd_loadseq: Could not malloc");
> -		memcpy(ahd->critical_sections, cs_table, cs_count);
>  	}
>  	ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
>  
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
> index c4829d8..3178730 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_core.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
> @@ -6940,10 +6940,10 @@ ahc_loadseq(struct ahc_softc *ahc)
>  	if (cs_count != 0) {
>  
>  		cs_count *= sizeof(struct cs);
> -		ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
> +		ahc->critical_sections = kmemdup(cs_table, cs_count,
> +						 GFP_ATOMIC);
>  		if (ahc->critical_sections == NULL)
>  			panic("ahc_loadseq: Could not malloc");
> -		memcpy(ahc->critical_sections, cs_table, cs_count);
>  	}
>  	ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
>  


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 20/31] fs/cifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 20/31] fs/cifs: " Andrzej Hajda
@ 2015-09-16 10:03   ` Andrzej Hajda
  2015-09-17  5:00   ` Steve French
  1 sibling, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:03 UTC (permalink / raw)
  To: Steve French
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, linux-cifs

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/cifs/smb2pdu.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 070fb2a..2d6b72f 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -1394,14 +1394,13 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>  		goto ioctl_exit;
>  	}
>  
> -	*out_data = kmalloc(*plen, GFP_KERNEL);
> +	*out_data = kmemdup(rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
> +			    *plen, GFP_KERNEL);
>  	if (*out_data == NULL) {
>  		rc = -ENOMEM;
>  		goto ioctl_exit;
>  	}
>  
> -	memcpy(*out_data, rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
> -	       *plen);
>  ioctl_exit:
>  	free_rsp_buf(resp_buftype, rsp);
>  	return rc;


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 21/31] fs/dlm: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 21/31] fs/dlm: " Andrzej Hajda
@ 2015-09-16 10:03   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:03 UTC (permalink / raw)
  To: Christine Caulfield, David Teigland
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, cluster-devel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/dlm/lowcomms.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
> index 754fd6c..b31b32a 100644
> --- a/fs/dlm/lowcomms.c
> +++ b/fs/dlm/lowcomms.c
> @@ -1317,10 +1317,9 @@ static void init_local(void)
>  		if (dlm_our_addr(&sas, i))
>  			break;
>  
> -		addr = kmalloc(sizeof(*addr), GFP_NOFS);
> +		addr = kmemdup(&sas, sizeof(*addr), GFP_NOFS);
>  		if (!addr)
>  			break;
> -		memcpy(addr, &sas, sizeof(*addr));
>  		dlm_local_addr[dlm_local_count++] = addr;
>  	}
>  }


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 22/31] fs/ntfs: " Andrzej Hajda
@ 2015-09-16 10:04   ` Andrzej Hajda
  2015-09-23 10:21   ` Anton Altaparmakov
  1 sibling, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:04 UTC (permalink / raw)
  To: Anton Altaparmakov
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-ntfs-dev

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/ntfs/dir.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
> index 9e38daf..2b7fef0 100644
> --- a/fs/ntfs/dir.c
> +++ b/fs/ntfs/dir.c
> @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
>  	 * map the mft record without deadlocking.
>  	 */
>  	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
> -	ir = kmalloc(rc, GFP_NOFS);
> +	/* Copy the index root value (it has been verified in read_inode). */
> +	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
> +		     rc, GFP_NOFS);
>  	if (unlikely(!ir)) {
>  		err = -ENOMEM;
>  		goto err_out;
>  	}
> -	/* Copy the index root value (it has been verified in read_inode). */
> -	memcpy(ir, (u8*)ctx->attr +
> -			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
>  	ntfs_attr_put_search_ctx(ctx);
>  	unmap_mft_record(ndir);
>  	ctx = NULL;


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 23/31] fs/ocfs2: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 23/31] fs/ocfs2: " Andrzej Hajda
@ 2015-09-16 10:04   ` Andrzej Hajda
  0 siblings, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:04 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel, ocfs2-devel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/ocfs2/localalloc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
> index 0a4457f..194d6d6 100644
> --- a/fs/ocfs2/localalloc.c
> +++ b/fs/ocfs2/localalloc.c
> @@ -434,12 +434,11 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
>  	bh = osb->local_alloc_bh;
>  	alloc = (struct ocfs2_dinode *) bh->b_data;
>  
> -	alloc_copy = kmalloc(bh->b_size, GFP_NOFS);
> +	alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS);
>  	if (!alloc_copy) {
>  		status = -ENOMEM;
>  		goto out_commit;
>  	}
> -	memcpy(alloc_copy, alloc, bh->b_size);
>  
>  	status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode),
>  					 bh, OCFS2_JOURNAL_ACCESS_WRITE);
> @@ -1285,13 +1284,12 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
>  	 * local alloc shutdown won't try to double free main bitmap
>  	 * bits. Make a copy so the sync function knows which bits to
>  	 * free. */
> -	alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_NOFS);
> +	alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS);
>  	if (!alloc_copy) {
>  		status = -ENOMEM;
>  		mlog_errno(status);
>  		goto bail;
>  	}
> -	memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
>  
>  	status = ocfs2_journal_access_di(handle,
>  					 INODE_CACHE(local_alloc_inode),


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 24/31] fs/omfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 24/31] fs/omfs: " Andrzej Hajda
  2015-08-07 12:22   ` Bob Copeland
@ 2015-09-16 10:05   ` Andrzej Hajda
  1 sibling, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:05 UTC (permalink / raw)
  To: Bob Copeland
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-karma-devel

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/omfs/inode.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
> index 3d935c8..02af1a3 100644
> --- a/fs/omfs/inode.c
> +++ b/fs/omfs/inode.c
> @@ -333,12 +333,11 @@ static int omfs_get_imap(struct super_block *sb)
>  		bh = sb_bread(sb, block++);
>  		if (!bh)
>  			goto nomem_free;
> -		*ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
> +		*ptr = kmemdup(bh->b_data, sb->s_blocksize, GFP_KERNEL);
>  		if (!*ptr) {
>  			brelse(bh);
>  			goto nomem_free;
>  		}
> -		memcpy(*ptr, bh->b_data, sb->s_blocksize);
>  		if (count < sb->s_blocksize)
>  			memset((void *)*ptr + count, 0xff,
>  				sb->s_blocksize - count);


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 01/31] arch/arm/mach-lpc32xx: use kmemdup rather than duplicating its implementation
  2015-09-16  9:52   ` Andrzej Hajda
@ 2015-09-16 10:06     ` Arnd Bergmann
  0 siblings, 0 replies; 76+ messages in thread
From: Arnd Bergmann @ 2015-09-16 10:06 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Andrzej Hajda, Roland Stigge, Marek Szyprowski, linux-kernel,
	Bartlomiej Zolnierkiewicz

On Wednesday 16 September 2015 11:52:37 Andrzej Hajda wrote:
> > @@ -87,7 +87,8 @@ static int lpc32xx_pm_enter(suspend_state_t state)
> >       void *iram_swap_area;
> >  
> >       /* Allocate some space for temporary IRAM storage */
> > -     iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL);
> > +     iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA,
> > +                              lpc32xx_sys_suspend_sz, GFP_KERNEL);
> >       if (!iram_swap_area) {
> >               printk(KERN_ERR
> >                      "PM Suspend: cannot allocate memory to save portion "
> > @@ -95,10 +96,6 @@ static int lpc32xx_pm_enter(suspend_state_t state)
> >               return -ENOMEM;
> >       }
> >  
> > -     /* Backup a small area of IRAM used for the suspend code */
> > -     memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA,
> > -             lpc32xx_sys_suspend_sz);
> 

Hmm, the patch looks correct in principle, but I think I'd rather leave the
original version with the comment in place, because the source is not
just random memory but instead some SRAM.

We might want to use memcpy_fromio()/memcpy_toio here and remove the cast for
both copies instead.

	Arnd

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 27/31] net/tipc: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 27/31] net/tipc: " Andrzej Hajda
@ 2015-09-16 10:07   ` Andrzej Hajda
  2015-09-17  9:58     ` Jon Maloy
  2015-09-17  1:19   ` Ying Xue
  1 sibling, 1 reply; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-16 10:07 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	David S. Miller, netdev

Ping.

Regards
Andrzej

On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  net/tipc/server.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/tipc/server.c b/net/tipc/server.c
> index 922e04a..c187cad 100644
> --- a/net/tipc/server.c
> +++ b/net/tipc/server.c
> @@ -411,13 +411,12 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
>  	if (!entry)
>  		return NULL;
>  
> -	buf = kmalloc(len, GFP_ATOMIC);
> +	buf = kmemdup(data, len, GFP_ATOMIC);
>  	if (!buf) {
>  		kfree(entry);
>  		return NULL;
>  	}
>  
> -	memcpy(buf, data, len);
>  	entry->iov.iov_base = buf;
>  	entry->iov.iov_len = len;
>  


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 12/31] drm/amdgpu: use kmemdup rather than duplicating its implementation
  2015-09-16  9:56   ` Andrzej Hajda
@ 2015-09-16 16:21     ` Christian König
  2015-09-21 21:36       ` Alex Deucher
  0 siblings, 1 reply; 76+ messages in thread
From: Christian König @ 2015-09-16 16:21 UTC (permalink / raw)
  To: Andrzej Hajda, Alex Deucher, Christian König, David Airlie
  Cc: Marek Szyprowski, linux-kernel, dri-devel, Bartlomiej Zolnierkiewicz

On 16.09.2015 11:56, Andrzej Hajda wrote:
> Ping.
>
> Regards
> Andrzej
>
> On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
>> The patch was generated using fixed coccinelle semantic patch
>> scripts/coccinelle/api/memdup.cocci [1].
>>
>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Somehow missed that. Patch is Reviewed-by: Christian König 
<christian.koenig@amd.com>.

Regards,
Christian.

>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> index 8da6424..94bd992 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>> @@ -549,12 +549,10 @@ int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata,
>>   	if (metadata == NULL)
>>   		return -EINVAL;
>>   
>> -	buffer = kzalloc(metadata_size, GFP_KERNEL);
>> +	buffer = kmemdup(metadata, metadata_size, GFP_KERNEL);
>>   	if (buffer == NULL)
>>   		return -ENOMEM;
>>   
>> -	memcpy(buffer, metadata, metadata_size);
>> -
>>   	kfree(bo->metadata);
>>   	bo->metadata_flags = flags;
>>   	bo->metadata = buffer;
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 27/31] net/tipc: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 27/31] net/tipc: " Andrzej Hajda
  2015-09-16 10:07   ` Andrzej Hajda
@ 2015-09-17  1:19   ` Ying Xue
  1 sibling, 0 replies; 76+ messages in thread
From: Ying Xue @ 2015-09-17  1:19 UTC (permalink / raw)
  To: Andrzej Hajda, Jon Maloy
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	David S. Miller, netdev

On 08/07/2015 03:59 PM, Andrzej Hajda wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>

Reviewed-by: Ying Xue <ying.xue@windriver.com>

> ---
>  net/tipc/server.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/tipc/server.c b/net/tipc/server.c
> index 922e04a..c187cad 100644
> --- a/net/tipc/server.c
> +++ b/net/tipc/server.c
> @@ -411,13 +411,12 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
>  	if (!entry)
>  		return NULL;
>  
> -	buf = kmalloc(len, GFP_ATOMIC);
> +	buf = kmemdup(data, len, GFP_ATOMIC);
>  	if (!buf) {
>  		kfree(entry);
>  		return NULL;
>  	}
>  
> -	memcpy(buf, data, len);
>  	entry->iov.iov_base = buf;
>  	entry->iov.iov_len = len;
>  
> 


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 20/31] fs/cifs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 20/31] fs/cifs: " Andrzej Hajda
  2015-09-16 10:03   ` Andrzej Hajda
@ 2015-09-17  5:00   ` Steve French
  1 sibling, 0 replies; 76+ messages in thread
From: Steve French @ 2015-09-17  5:00 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Steve French, Bartlomiej Zolnierkiewicz, Marek Szyprowski, LKML,
	linux-cifs

loooks reasonable to me - isn't this part of a larger patch series
though? Did you want it merged distinctly into cifs-2.6.git?

On Fri, Aug 7, 2015 at 2:59 AM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
>
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  fs/cifs/smb2pdu.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 070fb2a..2d6b72f 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -1394,14 +1394,13 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>                 goto ioctl_exit;
>         }
>
> -       *out_data = kmalloc(*plen, GFP_KERNEL);
> +       *out_data = kmemdup(rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
> +                           *plen, GFP_KERNEL);
>         if (*out_data == NULL) {
>                 rc = -ENOMEM;
>                 goto ioctl_exit;
>         }
>
> -       memcpy(*out_data, rsp->hdr.ProtocolId + le32_to_cpu(rsp->OutputOffset),
> -              *plen);
>  ioctl_exit:
>         free_rsp_buf(resp_buftype, rsp);
>         return rc;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 76+ messages in thread

* RE: [PATCH 27/31] net/tipc: use kmemdup rather than duplicating its implementation
  2015-09-16 10:07   ` Andrzej Hajda
@ 2015-09-17  9:58     ` Jon Maloy
  0 siblings, 0 replies; 76+ messages in thread
From: Jon Maloy @ 2015-09-17  9:58 UTC (permalink / raw)
  To: Andrzej Hajda, Ying Xue
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	David S. Miller, netdev

Acked-by: Jon Maloy <jon.maloy@ericsson.com>

///jon

> -----Original Message-----
> From: Andrzej Hajda [mailto:a.hajda@samsung.com]
> Sent: Wednesday, 16 September, 2015 06:07
> To: Jon Maloy; Ying Xue
> Cc: Bartlomiej Zolnierkiewicz; Marek Szyprowski; linux-
> kernel@vger.kernel.org; David S. Miller; netdev@vger.kernel.org
> Subject: Re: [PATCH 27/31] net/tipc: use kmemdup rather than duplicating its
> implementation
> 
> Ping.
> 
> Regards
> Andrzej
> 
> On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
> > The patch was generated using fixed coccinelle semantic patch
> > scripts/coccinelle/api/memdup.cocci [1].
> >
> > [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> >
> > Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> > ---
> >  net/tipc/server.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/net/tipc/server.c b/net/tipc/server.c index
> > 922e04a..c187cad 100644
> > --- a/net/tipc/server.c
> > +++ b/net/tipc/server.c
> > @@ -411,13 +411,12 @@ static struct outqueue_entry
> *tipc_alloc_entry(void *data, int len)
> >  	if (!entry)
> >  		return NULL;
> >
> > -	buf = kmalloc(len, GFP_ATOMIC);
> > +	buf = kmemdup(data, len, GFP_ATOMIC);
> >  	if (!buf) {
> >  		kfree(entry);
> >  		return NULL;
> >  	}
> >
> > -	memcpy(buf, data, len);
> >  	entry->iov.iov_base = buf;
> >  	entry->iov.iov_len = len;
> >


^ permalink raw reply	[flat|nested] 76+ messages in thread

* [tip:x86/platform] arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 08/31] arch/x86/intel-mid: " Andrzej Hajda
  2015-09-16  9:54   ` Andrzej Hajda
@ 2015-09-17 21:42   ` tip-bot for Andrzej Hajda
  1 sibling, 0 replies; 76+ messages in thread
From: tip-bot for Andrzej Hajda @ 2015-09-17 21:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: m.szyprowski, Julia.Lawall, hpa, mingo, tglx, a.hajda,
	b.zolnierkie, linux-kernel

Commit-ID:  c9e69c8c58eb8671e9f6cee728088e4c5abc9115
Gitweb:     http://git.kernel.org/tip/c9e69c8c58eb8671e9f6cee728088e4c5abc9115
Author:     Andrzej Hajda <a.hajda@samsung.com>
AuthorDate: Fri, 7 Aug 2015 09:59:14 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 17 Sep 2015 23:38:59 +0200

arch/x86/intel-mid: Use kmemdup rather than duplicating its implementation

The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Link: http://lkml.kernel.org/r/1438934377-4922-9-git-send-email-a.hajda@samsung.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/intel-mid/sfi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index ce992e8..5ee360a 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -197,10 +197,9 @@ static int __init sfi_parse_gpio(struct sfi_table_header *table)
 	num = SFI_GET_NUM_ENTRIES(sb, struct sfi_gpio_table_entry);
 	pentry = (struct sfi_gpio_table_entry *)sb->pentry;
 
-	gpio_table = kmalloc(num * sizeof(*pentry), GFP_KERNEL);
+	gpio_table = kmemdup(pentry, num * sizeof(*pentry), GFP_KERNEL);
 	if (!gpio_table)
 		return -1;
-	memcpy(gpio_table, pentry, num * sizeof(*pentry));
 	gpio_num_entry = num;
 
 	pr_debug("GPIO pin info:\n");

^ permalink raw reply related	[flat|nested] 76+ messages in thread

* Re: [PATCH 12/31] drm/amdgpu: use kmemdup rather than duplicating its implementation
  2015-09-16 16:21     ` Christian König
@ 2015-09-21 21:36       ` Alex Deucher
  0 siblings, 0 replies; 76+ messages in thread
From: Alex Deucher @ 2015-09-21 21:36 UTC (permalink / raw)
  To: Christian König
  Cc: Andrzej Hajda, Alex Deucher, Christian König, David Airlie,
	Bartlomiej Zolnierkiewicz, LKML, Maling list - DRI developers,
	Marek Szyprowski

On Wed, Sep 16, 2015 at 12:21 PM, Christian König
<deathsimple@vodafone.de> wrote:
> On 16.09.2015 11:56, Andrzej Hajda wrote:
>>
>> Ping.
>>
>> Regards
>> Andrzej
>>
>> On 08/07/2015 09:59 AM, Andrzej Hajda wrote:
>>>
>>> The patch was generated using fixed coccinelle semantic patch
>>> scripts/coccinelle/api/memdup.cocci [1].
>>>
>>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>>>
>>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>
>
> Somehow missed that. Patch is Reviewed-by: Christian König
> <christian.koenig@amd.com>.

I hadn't seen it either.  Applied now.

Alex

>
> Regards,
> Christian.
>
>
>>> ---
>>>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +---
>>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> index 8da6424..94bd992 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
>>> @@ -549,12 +549,10 @@ int amdgpu_bo_set_metadata (struct amdgpu_bo *bo,
>>> void *metadata,
>>>         if (metadata == NULL)
>>>                 return -EINVAL;
>>>   -     buffer = kzalloc(metadata_size, GFP_KERNEL);
>>> +       buffer = kmemdup(metadata, metadata_size, GFP_KERNEL);
>>>         if (buffer == NULL)
>>>                 return -ENOMEM;
>>>   -     memcpy(buffer, metadata, metadata_size);
>>> -
>>>         kfree(bo->metadata);
>>>         bo->metadata_flags = flags;
>>>         bo->metadata = buffer;
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
  2015-08-07  7:59 ` [PATCH 22/31] fs/ntfs: " Andrzej Hajda
  2015-09-16 10:04   ` Andrzej Hajda
@ 2015-09-23 10:21   ` Anton Altaparmakov
  2015-09-24  8:34     ` Andrzej Hajda
       [not found]     ` <fc4b273eb58a4c33b4e80270a7fd06b1@nebula-exfe-01.nebula.local>
  1 sibling, 2 replies; 76+ messages in thread
From: Anton Altaparmakov @ 2015-09-23 10:21 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-ntfs-dev

Hi Andrzej,

Thanks for your patch.  It looks fine though I don't quite see the point of it to be honest.

It actually adds an additional function call (kmemdup() is not inline) just to save 1 line of source code in the driver and I don't think it improves readability or anything so why bother?  What does it gain?

Best regards,

	Anton

> On 7 Aug 2015, at 08:59, Andrzej Hajda <a.hajda@samsung.com> wrote:
> 
> The patch was generated using fixed coccinelle semantic patch
> scripts/coccinelle/api/memdup.cocci [1].
> 
> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> fs/ntfs/dir.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
> index 9e38daf..2b7fef0 100644
> --- a/fs/ntfs/dir.c
> +++ b/fs/ntfs/dir.c
> @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
> 	 * map the mft record without deadlocking.
> 	 */
> 	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
> -	ir = kmalloc(rc, GFP_NOFS);
> +	/* Copy the index root value (it has been verified in read_inode). */
> +	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
> +		     rc, GFP_NOFS);
> 	if (unlikely(!ir)) {
> 		err = -ENOMEM;
> 		goto err_out;
> 	}
> -	/* Copy the index root value (it has been verified in read_inode). */
> -	memcpy(ir, (u8*)ctx->attr +
> -			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
> 	ntfs_attr_put_search_ctx(ctx);
> 	unmap_mft_record(ndir);
> 	ctx = NULL;
> -- 
> 1.9.1

-- 
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
  2015-09-23 10:21   ` Anton Altaparmakov
@ 2015-09-24  8:34     ` Andrzej Hajda
       [not found]     ` <fc4b273eb58a4c33b4e80270a7fd06b1@nebula-exfe-01.nebula.local>
  1 sibling, 0 replies; 76+ messages in thread
From: Andrzej Hajda @ 2015-09-24  8:34 UTC (permalink / raw)
  To: Anton Altaparmakov
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-ntfs-dev

On 09/23/2015 12:21 PM, Anton Altaparmakov wrote:
> Hi Andrzej,
>
> Thanks for your patch.  It looks fine though I don't quite see the point of it to be honest.
>
> It actually adds an additional function call (kmemdup() is not inline) just to save 1 line of source code in the driver and I don't think it improves readability or anything so why bother?  What does it gain?

kmemdup replaces combo (kmalloc + memdup) with one call.
The patch follows quite common practice of abstracting out common patterns.

Regards
Andrzej

>
> Best regards,
>
> 	Anton
>
>> On 7 Aug 2015, at 08:59, Andrzej Hajda <a.hajda@samsung.com> wrote:
>>
>> The patch was generated using fixed coccinelle semantic patch
>> scripts/coccinelle/api/memdup.cocci [1].
>>
>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>> fs/ntfs/dir.c | 7 +++----
>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
>> index 9e38daf..2b7fef0 100644
>> --- a/fs/ntfs/dir.c
>> +++ b/fs/ntfs/dir.c
>> @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
>> 	 * map the mft record without deadlocking.
>> 	 */
>> 	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
>> -	ir = kmalloc(rc, GFP_NOFS);
>> +	/* Copy the index root value (it has been verified in read_inode). */
>> +	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
>> +		     rc, GFP_NOFS);
>> 	if (unlikely(!ir)) {
>> 		err = -ENOMEM;
>> 		goto err_out;
>> 	}
>> -	/* Copy the index root value (it has been verified in read_inode). */
>> -	memcpy(ir, (u8*)ctx->attr +
>> -			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
>> 	ntfs_attr_put_search_ctx(ctx);
>> 	unmap_mft_record(ndir);
>> 	ctx = NULL;
>> -- 
>> 1.9.1


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
       [not found]     ` <fc4b273eb58a4c33b4e80270a7fd06b1@nebula-exfe-01.nebula.local>
@ 2015-09-24  9:20       ` Anton Altaparmakov
  2015-09-24  9:22         ` Anton Altaparmakov
  0 siblings, 1 reply; 76+ messages in thread
From: Anton Altaparmakov @ 2015-09-24  9:20 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-ntfs-dev

Hi Andrzej,

> On 24 Sep 2015, at 09:34, Andrzej Hajda <a.hajda@samsung.com> wrote:
> 
> On 09/23/2015 12:21 PM, Anton Altaparmakov wrote:
>> Hi Andrzej,
>> 
>> Thanks for your patch.  It looks fine though I don't quite see the point of it to be honest.
>> 
>> It actually adds an additional function call (kmemdup() is not inline) just to save 1 line of source code in the driver and I don't think it improves readability or anything so why bother?  What does it gain?
> 
> kmemdup replaces combo (kmalloc + memdup) with one call.
> The patch follows quite common practice of abstracting out common patterns.

Sure it does I am just questioning the sanity of the practice...  (-;

Such changes reduce the size of the kernel binary by a few bytes at the cost of adding CPU cycles to the execution time.  How is that good thing?  Unless you are on an embedded system desperate for RAM throwing away CPU cycles on pointless abstractions makes no sense to me...

But as I said patch is fine.  Feel free to send it onto Andrew to get it into mainline.  You can add my Acked-by: Anton Altaparmakoc <anton@tuxera.com> line to it when sending it.  I am just saying that I think patches like that don't make much sense to me...

Best regards,

	Anton

> Regards
> Andrzej
> 
>> 
>> Best regards,
>> 
>> 	Anton
>> 
>>> On 7 Aug 2015, at 08:59, Andrzej Hajda <a.hajda@samsung.com> wrote:
>>> 
>>> The patch was generated using fixed coccinelle semantic patch
>>> scripts/coccinelle/api/memdup.cocci [1].
>>> 
>>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>>> 
>>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>>> ---
>>> fs/ntfs/dir.c | 7 +++----
>>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
>>> index 9e38daf..2b7fef0 100644
>>> --- a/fs/ntfs/dir.c
>>> +++ b/fs/ntfs/dir.c
>>> @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
>>> 	 * map the mft record without deadlocking.
>>> 	 */
>>> 	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
>>> -	ir = kmalloc(rc, GFP_NOFS);
>>> +	/* Copy the index root value (it has been verified in read_inode). */
>>> +	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
>>> +		     rc, GFP_NOFS);
>>> 	if (unlikely(!ir)) {
>>> 		err = -ENOMEM;
>>> 		goto err_out;
>>> 	}
>>> -	/* Copy the index root value (it has been verified in read_inode). */
>>> -	memcpy(ir, (u8*)ctx->attr +
>>> -			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
>>> 	ntfs_attr_put_search_ctx(ctx);
>>> 	unmap_mft_record(ndir);
>>> 	ctx = NULL;
>>> -- 
>>> 1.9.1

-- 
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: [PATCH 22/31] fs/ntfs: use kmemdup rather than duplicating its implementation
  2015-09-24  9:20       ` Anton Altaparmakov
@ 2015-09-24  9:22         ` Anton Altaparmakov
  0 siblings, 0 replies; 76+ messages in thread
From: Anton Altaparmakov @ 2015-09-24  9:22 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: Bartlomiej Zolnierkiewicz, Marek Szyprowski, linux-kernel,
	linux-ntfs-dev


> On 24 Sep 2015, at 10:20, Anton Altaparmakov <anton@tuxera.com> wrote:
> 
> Hi Andrzej,
> 
>> On 24 Sep 2015, at 09:34, Andrzej Hajda <a.hajda@samsung.com> wrote:
>> 
>> On 09/23/2015 12:21 PM, Anton Altaparmakov wrote:
>>> Hi Andrzej,
>>> 
>>> Thanks for your patch.  It looks fine though I don't quite see the point of it to be honest.
>>> 
>>> It actually adds an additional function call (kmemdup() is not inline) just to save 1 line of source code in the driver and I don't think it improves readability or anything so why bother?  What does it gain?
>> 
>> kmemdup replaces combo (kmalloc + memdup) with one call.
>> The patch follows quite common practice of abstracting out common patterns.
> 
> Sure it does I am just questioning the sanity of the practice...  (-;
> 
> Such changes reduce the size of the kernel binary by a few bytes at the cost of adding CPU cycles to the execution time.  How is that good thing?  Unless you are on an embedded system desperate for RAM throwing away CPU cycles on pointless abstractions makes no sense to me...
> 
> But as I said patch is fine.  Feel free to send it onto Andrew to get it into mainline.  You can add my Acked-by: Anton Altaparmakoc <anton@tuxera.com>

Altaparmakov even.  Can't even spell my own surname...  )-;

> line to it when sending it.  I am just saying that I think patches like that don't make much sense to me...
> 
> Best regards,
> 
> 	Anton
> 
>> Regards
>> Andrzej
>> 
>>> 
>>> Best regards,
>>> 
>>> 	Anton
>>> 
>>>> On 7 Aug 2015, at 08:59, Andrzej Hajda <a.hajda@samsung.com> wrote:
>>>> 
>>>> The patch was generated using fixed coccinelle semantic patch
>>>> scripts/coccinelle/api/memdup.cocci [1].
>>>> 
>>>> [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320
>>>> 
>>>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>>>> ---
>>>> fs/ntfs/dir.c | 7 +++----
>>>> 1 file changed, 3 insertions(+), 4 deletions(-)
>>>> 
>>>> diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
>>>> index 9e38daf..2b7fef0 100644
>>>> --- a/fs/ntfs/dir.c
>>>> +++ b/fs/ntfs/dir.c
>>>> @@ -1172,14 +1172,13 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
>>>> 	 * map the mft record without deadlocking.
>>>> 	 */
>>>> 	rc = le32_to_cpu(ctx->attr->data.resident.value_length);
>>>> -	ir = kmalloc(rc, GFP_NOFS);
>>>> +	/* Copy the index root value (it has been verified in read_inode). */
>>>> +	ir = kmemdup((u8 *)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset),
>>>> +		     rc, GFP_NOFS);
>>>> 	if (unlikely(!ir)) {
>>>> 		err = -ENOMEM;
>>>> 		goto err_out;
>>>> 	}
>>>> -	/* Copy the index root value (it has been verified in read_inode). */
>>>> -	memcpy(ir, (u8*)ctx->attr +
>>>> -			le16_to_cpu(ctx->attr->data.resident.value_offset), rc);
>>>> 	ntfs_attr_put_search_ctx(ctx);
>>>> 	unmap_mft_record(ndir);
>>>> 	ctx = NULL;
>>>> -- 
>>>> 1.9.1
> 
> -- 
> Anton Altaparmakov <anton at tuxera.com> (replace at with @)
> Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
> Linux NTFS maintainer

Best regards,

	Anton
-- 
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer


^ permalink raw reply	[flat|nested] 76+ messages in thread

end of thread, other threads:[~2015-09-24  9:22 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-07  7:59 [PATCH 00/31] use kmemdup rather than duplicating its implementation Andrzej Hajda
2015-08-07  7:59 ` [PATCH 01/31] arch/arm/mach-lpc32xx: " Andrzej Hajda
2015-09-16  9:52   ` Andrzej Hajda
2015-09-16 10:06     ` Arnd Bergmann
2015-08-07  7:59 ` [PATCH 02/31] arch/ia64/tioce: " Andrzej Hajda
2015-09-16  9:53   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 03/31] arch/m68k/bootinfo: " Andrzej Hajda
2015-08-07 10:23   ` Geert Uytterhoeven
2015-08-07  7:59 ` [PATCH 04/31] arch/mips/bcm47xx: " Andrzej Hajda
2015-08-09 20:14   ` Hauke Mehrtens
2015-08-07  7:59 ` [PATCH 05/31] arch/powerpc/nvram: " Andrzej Hajda
2015-08-07 19:46   ` Nathan Fontenot
2015-08-19 23:14   ` [05/31] " Michael Ellerman
2015-08-07  7:59 ` [PATCH 06/31] arch/powerpc/pseries: " Andrzej Hajda
2015-08-07 19:46   ` Nathan Fontenot
2015-08-19 23:14   ` [06/31] " Michael Ellerman
2015-08-07  7:59 ` [PATCH 07/31] arch/x86/microcode: " Andrzej Hajda
2015-08-07 16:30   ` Borislav Petkov
2015-08-07  7:59 ` [PATCH 08/31] arch/x86/intel-mid: " Andrzej Hajda
2015-09-16  9:54   ` Andrzej Hajda
2015-09-17 21:42   ` [tip:x86/platform] arch/x86/intel-mid: Use " tip-bot for Andrzej Hajda
2015-08-07  7:59 ` [PATCH 09/31] crypto: use " Andrzej Hajda
2015-08-07  8:05   ` Herbert Xu
2015-08-07  7:59 ` [PATCH 10/31] clk/mmp: " Andrzej Hajda
2015-08-07 22:17   ` Stephen Boyd
2015-08-07  7:59 ` [PATCH 11/31] cpufreq/sfi: " Andrzej Hajda
2015-08-07  8:58   ` Viresh Kumar
2015-08-07  7:59 ` [PATCH 12/31] drm/amdgpu: " Andrzej Hajda
2015-09-16  9:56   ` Andrzej Hajda
2015-09-16 16:21     ` Christian König
2015-09-21 21:36       ` Alex Deucher
2015-08-07  7:59 ` [PATCH 13/31] memstick: " Andrzej Hajda
2015-09-16  9:57   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 14/31] message/fusion: " Andrzej Hajda
2015-09-16 10:01   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 15/31] misc/vmw_vmci: " Andrzej Hajda
2015-09-16 10:01   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 16/31] net/cavium/liquidio: " Andrzej Hajda
2015-09-16 10:02   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 17/31] scsi/aacraid: " Andrzej Hajda
2015-09-16 10:02   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 18/31] scsi/aic7xxx: " Andrzej Hajda
2015-09-16 10:02   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 19/31] staging/lustre: " Andrzej Hajda
2015-08-07  7:59 ` [PATCH 20/31] fs/cifs: " Andrzej Hajda
2015-09-16 10:03   ` Andrzej Hajda
2015-09-17  5:00   ` Steve French
2015-08-07  7:59 ` [PATCH 21/31] fs/dlm: " Andrzej Hajda
2015-09-16 10:03   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 22/31] fs/ntfs: " Andrzej Hajda
2015-09-16 10:04   ` Andrzej Hajda
2015-09-23 10:21   ` Anton Altaparmakov
2015-09-24  8:34     ` Andrzej Hajda
     [not found]     ` <fc4b273eb58a4c33b4e80270a7fd06b1@nebula-exfe-01.nebula.local>
2015-09-24  9:20       ` Anton Altaparmakov
2015-09-24  9:22         ` Anton Altaparmakov
2015-08-07  7:59 ` [PATCH 23/31] fs/ocfs2: " Andrzej Hajda
2015-09-16 10:04   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 24/31] fs/omfs: " Andrzej Hajda
2015-08-07 12:22   ` Bob Copeland
2015-09-16 10:05   ` Andrzej Hajda
2015-08-07  7:59 ` [PATCH 25/31] fs/ubifs: " Andrzej Hajda
2015-08-08  9:12   ` Richard Weinberger
2015-08-10  8:16   ` Artem Bityutskiy
2015-08-07  7:59 ` [PATCH 26/31] net/sched: " Andrzej Hajda
2015-08-07 10:35   ` Daniel Borkmann
2015-08-07  7:59 ` [PATCH 27/31] net/tipc: " Andrzej Hajda
2015-09-16 10:07   ` Andrzej Hajda
2015-09-17  9:58     ` Jon Maloy
2015-09-17  1:19   ` Ying Xue
2015-08-07  7:59 ` [PATCH 28/31] net/xfrm: " Andrzej Hajda
2015-08-12 10:25   ` Steffen Klassert
2015-08-07  7:59 ` [PATCH 29/31] sound/oxfw: " Andrzej Hajda
2015-08-07 12:52   ` [alsa-devel] " Takashi Iwai
2015-08-07  7:59 ` [PATCH 30/31] sound/atom: " Andrzej Hajda
2015-08-07 12:29   ` Mark Brown
2015-08-07  7:59 ` [PATCH 31/31] sound/soc: " Andrzej Hajda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).