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 Thanks