From patchwork Sat Sep 10 19:57:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101816 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp192643qgf; Sat, 10 Sep 2016 12:58:54 -0700 (PDT) X-Received: by 10.98.147.22 with SMTP id b22mr10820174pfe.88.1473537531555; Sat, 10 Sep 2016 12:58:51 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id t10si11384591paz.39.2016.09.10.12.58.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Sep 2016 12:58:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bioPv-0006eW-OU; Sat, 10 Sep 2016 19:58:23 +0000 Received: from mout.kundenserver.de ([212.227.126.133]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bioPq-0006cv-B6 for linux-mtd@lists.infradead.org; Sat, 10 Sep 2016 19:58:19 +0000 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue005) with ESMTPA (Nemesis) id 0LnWsk-1b71ck0ua6-00hgFN; Sat, 10 Sep 2016 21:57:52 +0200 From: Arnd Bergmann To: Brian Norris Subject: [PATCH] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Date: Sat, 10 Sep 2016 21:57:35 +0200 Message-Id: <20160910195748.1360407-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:PXGiYS5Sg3kGe3cqsoHVDHyptsNYZJ9C871PcQuupr1eSNvIly/ unbEbqrbchhh9MecjK9KPJWK5CYc9Jrjbzv3fpLD4bKl/bJoOuC09VTTIEpWpnN99SzZISW qmKcShgplcfspMM+BhzTq0L+ct3PX4XR4RxZeqvzEL7ay2qqYcitlkTJFJwBj8ory7RBvhk DF7rCtHEnOAO+8neIB/YQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:WVJ8RJmLVpU=:xTT7iVABXd6kEAzNPSpplR h6MfVbacKIltY55RUZ3lMXSuEeiwzfX/tg40fP5IKgQ/DzfL69qjjn28HoCJNtbs0dbJLAQCP Ud2Mm8t3d78bLgluTUu9U2uP7n+Eo5T24mO8Oo1TSiIJp81YtwY/boctXv+7UmZ/F7Oj8bHoB BkEyQ4bc8wc2Ujqmzu1sn1NR4M55V4KHk5WNz9UnlhMiTOf480/F8ujKKAwASWHMKQF8KQpAn 3Rpe/lzQRpipLJFwwiH1KEwXfEaSZpFnbABpsR/pfySzaHHjS2XlXvcEM3mxPIYIRj9CGsJ5y gXYMSbz/+/tjtLvUI7iht71rPv5l2JmbUdD40ssgMUkStEPrVYrJRukaVuwO7qdiSey+EoJC0 5KrV6bQx1Z8S5+Ah5wP4EDeMmWJSa3lKkKfo8vmof5cm+bUGX2HiyTnggdR7pOrCDuoT9044a 3z5G0pZo2B7JyhKDksUPlNNiqbgY83kRXl7mwhM3CAgL9NeJj9nwidbP/O1ZT4Zwvrl6xuoy5 f8VZKWe8C30dlhi2vjPweZNcF8mQCL945YjvVf0LKyT5Ajg9NYA9MRT1ikpnIHGSlJUQPp/Kn LZXVp0deSzkyAkuOVjpwqcb182lR+Mpk2PCvlo7It6zS4fkBf+yp+u3inpdyHq7XyG9qkIRFT lMGpu1A8r7DbhWL4sw1mhyrQwS+v5Jh+XMuvqrXArjIwolGJaWCOpYBd+mWXicQh/jc0= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160910_125818_754404_8C77CBE1 X-CRM114-Status: GOOD ( 10.97 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.133 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.133 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, David Woodhouse , linux-kernel@vger.kernel.org, Arnd Bergmann , kernel-build-reports@lists.linaro.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org 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 --- drivers/mtd/maps/pmcmsp-flash.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.9.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c index 744ca5cacc9b..cf54420f943d 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;