Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683144 > unrolled thread

[PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

Started byHari Prasath <gehariprasath@gmail.com>
First post2017-07-07 14:00 +0200
Last post2017-07-07 15:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup Hari Prasath <gehariprasath@gmail.com> - 2017-07-07 14:00 +0200
    Re: [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup Alan Cox <alan@linux.intel.com> - 2017-07-07 14:00 +0200
      Re: [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup hari prasath <gehariprasath@gmail.com> - 2017-07-07 15:30 +0200

#1683144 — [PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup

FromHari Prasath <gehariprasath@gmail.com>
Date2017-07-07 14:00 +0200
Subject[PATCH] staging: atomisp: replace kmalloc & memcpy with kmemdup
Message-ID<u0A5r-3x2-1@gated-at.bofh.it>
kmemdup can be used to replace kmalloc followed by a memcpy.This was
pointed out by the coccinelle tool.

Signed-off-by: Hari Prasath <gehariprasath@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index 34cc56f..58d4619 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -146,12 +146,10 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
 		char *namebuffer;
 		int namelength = (int)strlen(name);
 
-		namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL);
+		namebuffer = (char *)kmemdup(name, namelength + 1, GFP_KERNEL);
 		if (namebuffer == NULL)
 			return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
 
-		memcpy(namebuffer, name, namelength + 1);
-
 		bd->name = fw_minibuffer[index].name = namebuffer;
 	} else {
 		bd->name = name;
-- 
2.10.0.GIT

[toc] | [next] | [standalone]


#1683147

FromAlan Cox <alan@linux.intel.com>
Date2017-07-07 14:00 +0200
Message-ID<u0A5r-3x2-7@gated-at.bofh.it>
In reply to#1683144
On Fri, 2017-07-07 at 17:20 +0530, Hari Prasath wrote:
> kmemdup can be used to replace kmalloc followed by a memcpy.This was
> pointed out by the coccinelle tool.

And kstrdup could do the job even better I think ?

Alan

[toc] | [prev] | [next] | [standalone]


#1683184

Fromhari prasath <gehariprasath@gmail.com>
Date2017-07-07 15:30 +0200
Message-ID<u0Bux-4As-3@gated-at.bofh.it>
In reply to#1683147
On 07-Jul-2017 5:25 PM, "Alan Cox" <alan@linux.intel.com> wrote:

On Fri, 2017-07-07 at 17:20 +0530, Hari Prasath wrote:
> kmemdup can be used to replace kmalloc followed by a memcpy.This was
> pointed out by the coccinelle tool.

And kstrdup could do the job even better I think ?
> Yes & thanks for pointing me that. I will send a v2 version.

-Hari

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web