From patchwork Fri May 5 19:47:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 98681 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp292756qge; Fri, 5 May 2017 12:48:30 -0700 (PDT) X-Received: by 10.84.225.130 with SMTP id u2mr31876478plj.91.1494013709932; Fri, 05 May 2017 12:48:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 144si6012850pfa.118.2017.05.05.12.48.29; Fri, 05 May 2017 12:48:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755543AbdEETs1 (ORCPT + 6 others); Fri, 5 May 2017 15:48:27 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:64832 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755535AbdEETsV (ORCPT ); Fri, 5 May 2017 15:48:21 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lgysp-1dsitI0fXL-00oZ7i; Fri, 05 May 2017 21:48:19 +0200 From: Arnd Bergmann To: Ben Hutchings Cc: stable@vger.kernel.org, Arnd Bergmann , Brian Norris Subject: [PATCH 3.16-stable 42/87] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Date: Fri, 5 May 2017 21:47:00 +0200 Message-Id: <20170505194745.3627137-43-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170505194745.3627137-1-arnd@arndb.de> References: <20170505194745.3627137-1-arnd@arndb.de> X-Provags-ID: V03:K0:T/QTRr/PFLJ5MkWonQEELucQseKsqyAvtnX6ZIeB+phB4VEpReV vIi0gdQxXJUgzsScMLs3aaugGjQjoqqpExjwyyL0aRHDdzjHwDzosNjOe7SMlxFEGUJMkB1 aOx6jZ1MXfgIs9VBSi3DiaA/IvxRtUzQKDUU6goujgudbCUSX6rNqNay9Bk1z4Dh05ZcK0O 764JXzEQIJyYXbR93YJhA== X-UI-Out-Filterresults: notjunk:1; V01:K0:mx0sjLk0crk=:P6sc6oKeZo9J0r+ZCdsHRH XctSs/eXNMYKZNXwH8hcKPL7FmlN9LUwjigycR89664jarw0QYTZbE0pg61rIppeTziWDQpoo CsYm30xewZF7SuzLHUI9OtwO2nYkQLtU7L7Kjk8kZVbz4hVJETQxL6SfwDR7TCwXgOYkxsO2W OUvwaFjnLI6uqgjILi8/L7zuIikvhDORTTy4wSZ1zTWq986n2xCZQnhltfby4MlHdS1RFMpfb FG97RBZ82Vw65g0ChTh690FZj6Yvib57h01hD6rTqauyf6Ka4sOLeT/s1WSQw0bFoZVwbXO5n cCJtpjVmLemfh+ynVPJvapE0CeEj0wTjwPIpzkpCEs8V+s0bwF2J/N6khrREj1XCKUbkFyWg5 Kh6aA6tRal/n29rBPlULfVzb7I0QyqXkdHpNdsDxcaxcuuQRI6Q6YB/do2rs1CqcpQ+7FKey8 0G4Qx3StdNwn5LHj3WMkVZY3ykfPWI0rGQvtk3S533ywBD5TJX8vFY5Xz8EjL548W+1PBDWSr oeOC1Toou/F4n9zc2XpBDfbbg1wrzfbbBMuCzoTjOIs/kkymaaB4cN1EDLcGvCygYxKzI43bs mUT6bieIce2cept64z4Shwa6H8sfIfnucl0hff+z8F3C5Rr9muUXnXd/sPGOceNKl+kiIHn3u hgbspIUpQaRRzUvWZNttl2Cy8/++/BTTYpUzYIbxr6atreaDGGjQOSeaQncJqtqsh4P8= Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit b3c3a0685e34e98172cf467e982a7a8a9a89d518 upstream. 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 Acked-by: Marek Vasut Signed-off-by: Brian Norris Signed-off-by: Arnd Bergmann --- drivers/mtd/maps/pmcmsp-flash.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.9.0 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;