From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1F44314B85 for ; Wed, 10 Sep 2025 10:01:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757498470; cv=none; b=Q7ofFK8BpumJiIoP9RxA4ESHBXqv24YWrefgAtyineLNSHQKGC+5DQHGDH1VlmXT04Up+bbY/3QoB5GbL9ACKeTy78xu2ptVMSfcV/GzN+u0mQHs2IJGBOZeTaxy1CkEsbtuUHq3VBS4yJhHCo273wUXuCu1mJc8lr8l2aQl3ZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757498470; c=relaxed/simple; bh=G54EZvV6TYh/6aRiLS/VHoanwwYRL6VCM+nMKElEI20=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JZ8ZL20l3zs2nugwBSnmpdcZPa1eGDKe1SyqtJym4B45XjkyYL04w68ZCtWoof910rlTa1eh+CUTOCXAEeh6IJlOw6i3Qwbf8wUNcdUo9KZTgUMbL8xRIin6LVf9U2Uk9ecMPuSf0Eq22KxqVZN7yDyrsdXZTku6+6Vfwy+AIH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j0ArAIPW; arc=none smtp.client-ip=140.211.166.138 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j0ArAIPW" Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8F6A583CA7 for ; Wed, 10 Sep 2025 10:01:08 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org X-Spam-Flag: NO X-Spam-Score: -2.101 X-Spam-Level: Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Y8re5r2D5tXT for ; Wed, 10 Sep 2025 10:01:08 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=leon@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org E4E0A83CA4 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E4E0A83CA4 Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=j0ArAIPW Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) by smtp1.osuosl.org (Postfix) with ESMTPS id E4E0A83CA4 for ; Wed, 10 Sep 2025 10:01:07 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 31DD26023C; Wed, 10 Sep 2025 10:01:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D25CC4CEF0; Wed, 10 Sep 2025 10:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1757498465; bh=G54EZvV6TYh/6aRiLS/VHoanwwYRL6VCM+nMKElEI20=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j0ArAIPWssOq42cLhTYSaTOOEJ3f4TBdM/d8YerpuWgBriQtXuyvU+81knfjxYXt5 NV1+P14kcqIt+EbTzbRGCUbdEM/UHfatAA2R5KTwKqiapdE1S25UYnLqPh7ObG7Lgv YeDAqGlHqMjJ7uhjLZU4hA1VFYuuIYBwwYRkkjN8rUoURyeU8StIcihBmdnXggdn1A sAug9yL8h/isBavawkJzfdFyz5tY01zNuSYyK+Nw3NzLC61UPM89My7GuKULLmoVte cVgTrHOnuIjWrK16Yok8x6ljiChFtIx+9pPfoP2Lnvy+XrJSa0QGT6mV886AjC6Ehz o3ai+1/N+usZw== Date: Wed, 10 Sep 2025 13:01:00 +0300 From: Leon Romanovsky To: Kriish Sharma Cc: alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com, wenjia@linux.ibm.com, mjambigi@linux.ibm.com, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [PATCH] net/smc: replace strncpy with strscpy for ib_name Message-ID: <20250910100100.GM341237@unreal> References: <20250908180913.356632-1-kriish.sharma2006@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel-mentees@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250908180913.356632-1-kriish.sharma2006@gmail.com> On Mon, Sep 08, 2025 at 06:09:13PM +0000, Kriish Sharma wrote: > Replace the deprecated strncpy() with strscpy() for ib_name in > smc_pnet_add_ib(). The destination buffer should be NUL-terminated and > does not require any trailing NUL-padding. Since ib_name is a fixed-size > array, the two-argument form of strscpy() is sufficient and preferred. > > Signed-off-by: Kriish Sharma > --- > net/smc/smc_pnet.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/smc/smc_pnet.c b/net/smc/smc_pnet.c > index 76ad29e31d60..b90337f86e83 100644 > --- a/net/smc/smc_pnet.c > +++ b/net/smc/smc_pnet.c > @@ -450,7 +450,7 @@ static int smc_pnet_add_ib(struct smc_pnettable *pnettable, char *ib_name, > return -ENOMEM; > new_pe->type = SMC_PNET_IB; > memcpy(new_pe->pnet_name, pnet_name, SMC_MAX_PNETID_LEN); > - strncpy(new_pe->ib_name, ib_name, IB_DEVICE_NAME_MAX); > + strscpy(new_pe->ib_name, ib_name); It is worth to mention that caching ib_name is wrong as IB/core provides IB device rename functionality. Thanks > new_pe->ib_port = ib_port; > > new_ibdev = true; > -- > 2.34.1 > >