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>
This commit is contained in:
Hari Prasath 2017-07-10 02:17:00 -04:00 committed by Mauro Carvalho Chehab
parent e9e8c1cd18
commit e199022254
1 changed files with 2 additions and 6 deletions

View File

@ -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;