Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp628192ybe; Wed, 11 Sep 2019 02:09:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMKZ/WM3IuEGV+zV/6QPiexnmHgPdiKC4hGL7brHjo0MNCoDC0WWbFGk8pFjeyzTXVAD5U X-Received: by 2002:a17:906:804d:: with SMTP id x13mr28436742ejw.134.1568192957379; Wed, 11 Sep 2019 02:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568192957; cv=none; d=google.com; s=arc-20160816; b=Q28sE9w0FC81e4cZ9b6KaCTlCBQh77vi9G1ecV1ca/5JRzM1LETqynlx8A/rMAPjVz dIuf16Riyj3SIFll8FrBIeu4uW7RMc69+GTHkA3cfI8ZFKIXZtx4bP98jNNZGOznQSM/ Om55aSqKkY21pDXxcMihFhWR1fYcp+sHdJS/UWIWASUDtEYVU8Jfda7TTgkeuE2kG3oa etl0+tRGDMHMHXD6Ztu3Q7ouAnfXK5zyejWnYXujpR0eOohbk5WnbLT8i1S5a8dLSDlK MWbT9NOuqomzl+LSMpc3bV70O4b/m9BSP2ks4rRebc+hUUgCqeVlLkzhtyb9TSfPMjtE MBGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding; bh=PyWmJFOAYwpvc2O1o7ejJW68UriKjQUDWvp/sFnJUdw=; b=R850hPGB8iQ4jnHlPu7YKymzDWTyrlMLg/4GR+ikuTygpq7FG5jCfxZyASNIW8iIZW qqrg/QVsSL4IWMU+1jHsEdnuk3fuJvfIN6z4mI5zdx+55TlRmdL60MAPDSG/p8S9a6KJ 9TUKlh7UT1/akDqCVwr7UJ1gaMdmCcIfXvdLiYaihYLAV0x4aa9JLq8b/76WgCahe7Em IKekXvNh4apGDWemux2RpIhNPs56V8yaVffQlCOAgBBmkDml71OTy/TKkPKYYdlN6cQb uf75YVnwXeAho5Fw4UBzApv5MiavwId0HiCZCJ42REduV8SI7TzwTpL0BH5IrOifnGt7 tKFw== 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 h4si12206162edd.189.2019.09.11.02.08.52; Wed, 11 Sep 2019 02:09:17 -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 S1727093AbfIKJEv convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Sep 2019 05:04:51 -0400 Received: from mxout012.mail.hostpoint.ch ([217.26.49.172]:13203 "EHLO mxout012.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbfIKJEu (ORCPT ); Wed, 11 Sep 2019 05:04:50 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout012.mail.hostpoint.ch with esmtp (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7yYJ-000Dkw-Uz; Wed, 11 Sep 2019 11:04:39 +0200 Received: from [213.55.220.251] (helo=[100.66.103.90]) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7yYJ-000NhF-QB; Wed, 11 Sep 2019 11:04:39 +0200 X-Authenticated-Sender-Id: sandro@volery.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT From: Sandro Volery Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] Staging: octeon: Avoid several usecases of strcpy Date: Wed, 11 Sep 2019 11:04:38 +0200 Message-Id: <39D8B984-479C-42D5-8431-9FF7BD3A96D6@volery.com> References: <20190911084956.GH15977@kadam> Cc: gregkh@linuxfoundation.org, davem@davemloft.net, aaro.koskinen@iki.fi, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org In-Reply-To: <20190911084956.GH15977@kadam> To: Dan Carpenter X-Mailer: iPhone Mail (17A5831c) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 11 Sep 2019, at 10:52, Dan Carpenter wrote: > > On Wed, Sep 11, 2019 at 08:23:59AM +0200, Sandro Volery wrote: >> strcpy was used multiple times in strcpy to write into dev->name. >> I replaced them with strscpy. >> >> Signed-off-by: Sandro Volery >> --- >> drivers/staging/octeon/ethernet.c | 16 ++++++++-------- >> 1 file changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c >> index 8889494adf1f..cf8e9a23ebf9 100644 >> --- a/drivers/staging/octeon/ethernet.c >> +++ b/drivers/staging/octeon/ethernet.c >> @@ -784,7 +784,7 @@ static int cvm_oct_probe(struct platform_device *pdev) >> priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; >> priv->port = CVMX_PIP_NUM_INPUT_PORTS; >> priv->queue = -1; >> - strcpy(dev->name, "pow%d"); >> + strscpy(dev->name, "pow%d", sizeof(dev->name)); > > Is there a program which is generating a warning for this code? We know > that "pow%d" is 6 characters and static analysis tools can understand > this code fine so we know it's safe. Well I was confused too but checkpatch complained about it so I figured I'd clean it up quick