[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e6b1dc1-5311-91ba-10e3-1a13f866df6b@gmail.com>
Date: Sat, 4 Feb 2017 22:12:35 +0100
From: Marek Vasut <marek.vasut@...il.com>
To: Arnd Bergmann <arnd@...db.de>,
Brian Norris <computersforpeace@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>,
Boris Brezillon <boris.brezillon@...e-electrons.com>,
Richard Weinberger <richard@....at>,
Cyrille Pitchen <cyrille.pitchen@...el.com>,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy
On 02/03/2017 10:49 AM, Arnd Bergmann wrote:
> 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: Arnd Bergmann <arnd@...db.de>
Acked-by: Marek Vasut <marek.vasut@...il.com>
> ---
> drivers/mtd/maps/pmcmsp-flash.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
> index f9fa3fad728e..2051f28ddac6 100644
> --- a/drivers/mtd/maps/pmcmsp-flash.c
> +++ b/drivers/mtd/maps/pmcmsp-flash.c
> @@ -139,15 +139,13 @@ static int __init init_msp_flash(void)
> }
>
> 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) {
> iounmap(msp_maps[i].virt);
> kfree(msp_parts[i]);
> goto cleanup_loop;
> }
>
> - msp_maps[i].name = strncpy(msp_maps[i].name, flash_name, 7);
> -
> for (j = 0; j < pcnt; j++) {
> part_name[5] = '0' + i;
> part_name[7] = '0' + j;
>
--
Best regards,
Marek Vasut
Powered by blists - more mailing lists