From: Hari Prasath Date: Mon, 10 Jul 2017 06:17:00 +0000 (-0400) Subject: media: staging: atomisp: use kstrdup to replace kmalloc and memcpy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e19902225473529c8b84579930fe66156cd1f258;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- 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;