Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name
@ 2026-10-09 13:17 Serhat Kumral
  2026-10-09 13:27 ` sashiko-bot
  2026-10-12  8:08 ` Leon Romanovsky
  0 siblings, 2 replies; 5+ messages in thread
From: Serhat Kumral @ 2026-10-09 13:17 UTC (permalink / raw)
  To: haris.iqbal, jinpu.wang
  Cc: jgg, leon, danil.kipnis, linux-rdma, linux-kernel, Serhat Kumral

As the comment states, the HCA name is cached for sysfs. Use
strscpy() to copy it directly without unnecessary formatting and
avoid interpreting format specifiers in the name.

Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
---
found by smatch:
- drivers/infiniband/ulp/rtrs/rtrs-clt.c:1906 rtrs_rdma_conn_established() warn: call of 'scnprintf' with non-constant format argument

 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 927e3f30483c..c85e22f670ba 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1918,8 +1918,8 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,
 		 * Cache the hca_port and hca_name for sysfs
 		 */
 		clt_path->hca_port = con->c.cm_id->port_num;
-		scnprintf(clt_path->hca_name, sizeof(clt_path->hca_name),
-			  clt_path->s.dev->ib_dev->name);
+		strscpy(clt_path->hca_name, clt_path->s.dev->ib_dev->name,
+			sizeof(clt_path->hca_name));
 		clt_path->s.src_addr = con->c.cm_id->route.addr.src_addr;
 		/* set for_new_clt, to allow future reconnect on any path */
 		clt_path->for_new_clt = 1;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name
  2026-10-09 13:17 [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name Serhat Kumral
@ 2026-10-09 13:27 ` sashiko-bot
  2026-10-12  8:08 ` Leon Romanovsky
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-09 13:27 UTC (permalink / raw)
  To: Serhat Kumral; +Cc: linux-rdma

> As the comment states, the HCA name is cached for sysfs. Use
> strscpy() to copy it directly without unnecessary formatting and
> avoid interpreting format specifiers in the name.
> 
> Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
> Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009131715.39217-1-serhatkumral1@gmail.com?part=1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name
  2026-10-09 13:17 [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name Serhat Kumral
  2026-10-09 13:27 ` sashiko-bot
@ 2026-10-12  8:08 ` Leon Romanovsky
  2026-10-12 13:11   ` Jinpu Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2026-10-12  8:08 UTC (permalink / raw)
  To: Serhat Kumral, haris.iqbal, jinpu.wang
  Cc: jgg, danil.kipnis, linux-rdma, linux-kernel

On Fri, Oct 09, 2026 at 04:17:15PM +0300, Serhat Kumral wrote:
> As the comment states, the HCA name is cached for sysfs. Use
> strscpy() to copy it directly without unnecessary formatting and
> avoid interpreting format specifiers in the name.
> 
> Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
> Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
> ---
> found by smatch:
> - drivers/infiniband/ulp/rtrs/rtrs-clt.c:1906 rtrs_rdma_conn_established() warn: call of 'scnprintf' with non-constant format argument
> 
>  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 927e3f30483c..c85e22f670ba 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -1918,8 +1918,8 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,
>  		 * Cache the hca_port and hca_name for sysfs
>  		 */
>  		clt_path->hca_port = con->c.cm_id->port_num;
> -		scnprintf(clt_path->hca_name, sizeof(clt_path->hca_name),
> -			  clt_path->s.dev->ib_dev->name);
> +		strscpy(clt_path->hca_name, clt_path->s.dev->ib_dev->name,
> +			sizeof(clt_path->hca_name));

Haris, Jinpu

These names shouldn't be cached.

Thanks

>  		clt_path->s.src_addr = con->c.cm_id->route.addr.src_addr;
>  		/* set for_new_clt, to allow future reconnect on any path */
>  		clt_path->for_new_clt = 1;
> -- 
> 2.53.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name
  2026-10-12  8:08 ` Leon Romanovsky
@ 2026-10-12 13:11   ` Jinpu Wang
  2026-10-13 10:20     ` Leon Romanovsky
  0 siblings, 1 reply; 5+ messages in thread
From: Jinpu Wang @ 2026-10-12 13:11 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Serhat Kumral, haris.iqbal, jgg, danil.kipnis, linux-rdma,
	linux-kernel

On Mon, Oct 12, 2026 at 10:08 AM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Fri, Oct 09, 2026 at 04:17:15PM +0300, Serhat Kumral wrote:
> > As the comment states, the HCA name is cached for sysfs. Use
> > strscpy() to copy it directly without unnecessary formatting and
> > avoid interpreting format specifiers in the name.
> >
> > Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
> > Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
> > ---
> > found by smatch:
> > - drivers/infiniband/ulp/rtrs/rtrs-clt.c:1906 rtrs_rdma_conn_established() warn: call of 'scnprintf' with non-constant format argument
> >
> >  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > index 927e3f30483c..c85e22f670ba 100644
> > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > @@ -1918,8 +1918,8 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,
> >                * Cache the hca_port and hca_name for sysfs
> >                */
> >               clt_path->hca_port = con->c.cm_id->port_num;
> > -             scnprintf(clt_path->hca_name, sizeof(clt_path->hca_name),
> > -                       clt_path->s.dev->ib_dev->name);
> > +             strscpy(clt_path->hca_name, clt_path->s.dev->ib_dev->name,
> > +                     sizeof(clt_path->hca_name));
>
> Haris, Jinpu
>
> These names shouldn't be cached.

Leon, you mean the hostname could change at runtime?

>
> Thanks
>
> >               clt_path->s.src_addr = con->c.cm_id->route.addr.src_addr;
> >               /* set for_new_clt, to allow future reconnect on any path */
> >               clt_path->for_new_clt = 1;
> > --
> > 2.53.0
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name
  2026-10-12 13:11   ` Jinpu Wang
@ 2026-10-13 10:20     ` Leon Romanovsky
  0 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2026-10-13 10:20 UTC (permalink / raw)
  To: Jinpu Wang
  Cc: Serhat Kumral, haris.iqbal, jgg, danil.kipnis, linux-rdma,
	linux-kernel

On Mon, Oct 12, 2026 at 03:11:05PM +0200, Jinpu Wang wrote:
> On Mon, Oct 12, 2026 at 10:08 AM Leon Romanovsky <leon@kernel.org> wrote:
> >
> > On Fri, Oct 09, 2026 at 04:17:15PM +0300, Serhat Kumral wrote:
> > > As the comment states, the HCA name is cached for sysfs. Use
> > > strscpy() to copy it directly without unnecessary formatting and
> > > avoid interpreting format specifiers in the name.
> > >
> > > Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
> > > Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
> > > ---
> > > found by smatch:
> > > - drivers/infiniband/ulp/rtrs/rtrs-clt.c:1906 rtrs_rdma_conn_established() warn: call of 'scnprintf' with non-constant format argument
> > >
> > >  drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > > index 927e3f30483c..c85e22f670ba 100644
> > > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> > > @@ -1918,8 +1918,8 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con,
> > >                * Cache the hca_port and hca_name for sysfs
> > >                */
> > >               clt_path->hca_port = con->c.cm_id->port_num;
> > > -             scnprintf(clt_path->hca_name, sizeof(clt_path->hca_name),
> > > -                       clt_path->s.dev->ib_dev->name);
> > > +             strscpy(clt_path->hca_name, clt_path->s.dev->ib_dev->name,
> > > +                     sizeof(clt_path->hca_name));
> >
> > Haris, Jinpu
> >
> > These names shouldn't be cached.
> 
> Leon, you mean the hostname could change at runtime?

Yes, users can change the hostname at any time. However, this code caches the
`ib_device` name, which can also change at any time.

Thanks

> 
> >
> > Thanks
> >
> > >               clt_path->s.src_addr = con->c.cm_id->route.addr.src_addr;
> > >               /* set for_new_clt, to allow future reconnect on any path */
> > >               clt_path->for_new_clt = 1;
> > > --
> > > 2.53.0
> > >

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-13 10:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09 13:17 [PATCH] RDMA/rtrs: Use strscpy() to cache the HCA name Serhat Kumral
2026-10-09 13:27 ` sashiko-bot
2026-10-12  8:08 ` Leon Romanovsky
2026-10-12 13:11   ` Jinpu Wang
2026-10-13 10:20     ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox