Commit 906b2684 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Brian Norris

mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy

kernelci.org reports a warning for this driver, as it copies a local
variable into a 'const char *' string:

    drivers/mtd/maps/pmcmsp-flash.c:149:30: warning: passing argument 1 of 'strncpy' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

Using kstrndup() simplifies the code and avoids the warning.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarMarek Vasut <marek.vasut@gmail.com>
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent 56ff337e
...@@ -139,15 +139,13 @@ static int __init init_msp_flash(void) ...@@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
} }
msp_maps[i].bankwidth = 1; msp_maps[i].bankwidth = 1;
msp_maps[i].name = kmalloc(7, GFP_KERNEL); msp_maps[i].name = kstrndup(flash_name, 7, GFP_KERNEL);
if (!msp_maps[i].name) { if (!msp_maps[i].name) {
iounmap(msp_maps[i].virt); iounmap(msp_maps[i].virt);
kfree(msp_parts[i]); kfree(msp_parts[i]);
goto cleanup_loop; goto cleanup_loop;
} }
msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
for (j = 0; j < pcnt; j++) { for (j = 0; j < pcnt; j++) {
part_name[5] = '0' + i; part_name[5] = '0' + i;
part_name[7] = '0' + j; part_name[7] = '0' + j;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment