From patchwork Mon Jun 19 18:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 105921 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1027893qgd; Mon, 19 Jun 2017 12:24:20 -0700 (PDT) X-Received: by 10.98.64.6 with SMTP id n6mr26588023pfa.196.1497900260193; Mon, 19 Jun 2017 12:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497900260; cv=none; d=google.com; s=arc-20160816; b=gFIBdmTCfox3DO7YB4a63TgUZupeDL6kHf4Hgo2z2PzW6+QjIiLYSvoN356zVicqE2 /Cd8npREN1NUCQiF22hHZK49R6MTLduNqYNKwSi+pwAMBHvQz6fNiOHejDPSKfpE2HEm vUuIHhRt1KlCf8ftPn4Bl8od3j/Wn23+eOtmB7kVh4h75UWGkX9AGZp51TFwZyXlS5WD 95tqKTZQTd8yF/+4FiFJ065U9S21smgqF/m5u/R9n5lBaqYIpBh03nhU+FT8uHHxCT8X b4V11bfuiOSuoDQ4EJuuQYOkp6h4z7m7UiRv8tkSyPId8cwapA8rxtW56JCF8dTDS/N2 Hn/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=l+mB5+MO11WShgyEiOkVtkAfb1Cm6oas90WSWpS5Y8g=; b=DH0Sp+NvmSUbMxCB+xSQgCG0vBDV4t7cxk0rvjehJ4eJTtEC/WUJiFIBViX0vHx4op xqRWwL7xn9MCVqxu8EZhNWCZznCUbt7xQsJloVPI6YohFrQUvmz6MHZ6vi6yFMVG8in2 e8bI/jI1iGFgk6Rbdw/mtGdWfLBfE75ALlflXCpF0kGGn3va3l2eKcNCKWscNdodx4Rz RagrAeHDzPUW8p0GrQFlkJfzlS51TLtSpR4dPz2urPwQeF6/9r6jJzXDlZh/kjpKbA6B 5OzpnOIpUi1v26iucNpfZLKS2Vd5GL7SizfKDaUHEQmSqr8ein1jcuoHFXrQY9QuPMEo t/AA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e63si8483264pgc.97.2017.06.19.12.24.19; Mon, 19 Jun 2017 12:24:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753282AbdFSTYC (ORCPT + 25 others); Mon, 19 Jun 2017 15:24:02 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:52123 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753035AbdFSSfc (ORCPT ); Mon, 19 Jun 2017 14:35:32 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id v5JIXg0r015041; Mon, 19 Jun 2017 20:33:42 +0200 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Arnd Bergmann , Brian Norris , Willy Tarreau Subject: [PATCH 3.10 175/268] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Date: Mon, 19 Jun 2017 20:31:14 +0200 Message-Id: <1497897167-14556-176-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1497897167-14556-1-git-send-email-w@1wt.eu> References: <1497897167-14556-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 906b268477bc03daaa04f739844c120fe4dbc991 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: Willy Tarreau --- drivers/mtd/maps/pmcmsp-flash.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.8.0.rc2.1.gbe9624a diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c index f9fa3fa..2051f28 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;