Re: [PATCH for-next 03/10] RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 2, 2021 at 8:52 AM Leon Romanovsky <leon@xxxxxxxxxx> wrote:
>
> On Fri, Jul 30, 2021 at 03:18:25PM +0200, Jack Wang wrote:
> > From: Md Haris Iqbal <haris.iqbal@xxxxxxxxx>
> >
> > sysfs_emit function was added to be aware of the PAGE_SIZE maximum of
> > the temporary buffer used for outputting sysfs content, so there is no
> > possible overruns. So replace the uses of any s*printf functions for
> > the sysfs show functions with sysfs_emit.
> >
> > Signed-off-by: Md Haris Iqbal <haris.iqbal@xxxxxxxxx>
> > Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxx>
> > ---
> >  drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 24 +++++++++-----------
> >  drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c |  2 +-
> >  2 files changed, 12 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c
> > index 26bbe5d6dff5..c5c047aa45a4 100644
> > --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c
> > +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c
> > @@ -45,24 +45,23 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,
> >       size_t used;
> >       int cpu;
> >
> > -     used = scnprintf(buf, len, "    ");
> > +     used = sysfs_emit(buf, "    ");
> >       for_each_possible_cpu(cpu)
> > -             used += scnprintf(buf + used, len - used, " CPU%u", cpu);
> > +             used += sysfs_emit_at(buf, used, " CPU%u", cpu);
> >
> > -     used += scnprintf(buf + used, len - used, "\nfrom:");
> > +     used += sysfs_emit_at(buf, used, "\nfrom:");
>
> "\nfrom" and "\nto" are abuse of sysfs rules.
> https://lore.kernel.org/kernelnewbies/7a353c64-a81f-a149-9541-ef328a197761@xxxxxxxxx/T/#m8bf898fcdb4a5371781bbc9646993a50fa950fbc
> https://lore.kernel.org/kernelnewbies/7a353c64-a81f-a149-9541-ef328a197761@xxxxxxxxx/T/#m9ce6f045a863597922012d71a6719d6d90c8e0a6

I see. We will discuss internally and see what can be done about this.

Thanks

>
> Thanks



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux