diff options
author | Hari Prasath <gehariprasath@gmail.com> | 2017-07-10 08:17:00 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-07-19 22:25:28 +0200 |
commit | e19902225473529c8b84579930fe66156cd1f258 (patch) | |
tree | 3387a359a735f962fe7544a7e11194daeae48911 | |
parent | media: staging: atomisp: gc2235: constify acpi_device_id (diff) | |
download | linux-e19902225473529c8b84579930fe66156cd1f258.tar.xz linux-e19902225473529c8b84579930fe66156cd1f258.zip |
media: staging: atomisp: use kstrdup to replace kmalloc and memcpy
kstrdup kernel primitive can be used to replace kmalloc followed by
string copy. This was reported by coccinelle tool.
Signed-off-by: Hari Prasath <gehariprasath@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r-- | drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c | 8 |
1 files changed, 2 insertions, 6 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 eecd8cf71951..63582161050a 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 @@ -131,14 +131,10 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia if (bi->type == ia_css_isp_firmware || bi->type == ia_css_sp_firmware) { char *namebuffer; - int namelength = (int)strlen(name); - namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL); - if (namebuffer == NULL) + namebuffer = kstrdup(name, GFP_KERNEL); + if (!namebuffer) return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; - - memcpy(namebuffer, name, namelength + 1); - bd->name = fw_minibuffer[index].name = namebuffer; } else { bd->name = name; |