Message ID | f4ce30f297be4678634b5be4917401767ee6ebc5.camel@perches.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | RDMA: usnic: Fix misuse of sysfs_emit_at | expand |
On Fri, 2021-01-15 at 13:23 -0800, Joe Perches wrote: > In commit e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs > _show > uses to sysfs_emit") I mistakenly used len = sysfs_emit_at to > overwrite > the last trailing space of potentially multiple entry output. > > The length of the last sysfs_emit_at call is 1 and it should instead > be > ignored. Do so. > > Fixes: e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs > _show uses to sysfs_emit") > > Reported-by: James Bottomley <James.Bottomley@HansenPartnership.com> > Signed-off-by: Joe Perches <joe@perches.com> > --- > drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > index e59615a4c9d9..fc077855b46c 100644 > --- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > +++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > @@ -231,7 +231,7 @@ static ssize_t summary_show(struct > usnic_ib_qp_grp *qp_grp, char *buf) > } > } > > - len = sysfs_emit_at(buf, len, "\n"); > + sysfs_emit_at(buf, len, "\n"); /* Overwrite the last > trailing space */ len is the offset of where the next character gets written, isn't it? so if you're overwriting the last character emitted into buf, shouldn't the offset point at that character rather than one beyond it? So sysfs_emit_at(buf, len - 1, "\n"); /* Overwrite the last trailing space */ ? James
On Fri, 2021-01-15 at 14:15 -0800, James Bottomley wrote: > On Fri, 2021-01-15 at 13:23 -0800, Joe Perches wrote: > > In commit e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs > > _show > > uses to sysfs_emit") I mistakenly used len = sysfs_emit_at to > > overwrite > > the last trailing space of potentially multiple entry output. > > > > The length of the last sysfs_emit_at call is 1 and it should instead > > be > > ignored. Do so. > > > > Fixes: e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs > > _show uses to sysfs_emit") > > > > Reported-by: James Bottomley <James.Bottomley@HansenPartnership.com> > > Signed-off-by: Joe Perches <joe@perches.com> > > --- > > drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > > b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > > index e59615a4c9d9..fc077855b46c 100644 > > --- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > > +++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c > > @@ -231,7 +231,7 @@ static ssize_t summary_show(struct > > usnic_ib_qp_grp *qp_grp, char *buf) > > } > > } > > > > > > - len = sysfs_emit_at(buf, len, "\n"); > > + sysfs_emit_at(buf, len, "\n"); /* Overwrite the last > > trailing space */ > > len is the offset of where the next character gets written, isn't it? > so if you're overwriting the last character emitted into buf, shouldn't > the offset point at that character rather than one beyond it? So > > sysfs_emit_at(buf, len - 1, "\n"); /* Overwrite the last trailing > space */ <sigh> quite right, thanks for catching yet another braino from me today. I'll step away from the keyboard and go back to doing other things today after submitting a V2 with a more typical style without the silly backspace/newline by trimming the trailing space from the formats...
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c index e59615a4c9d9..fc077855b46c 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c @@ -231,7 +231,7 @@ static ssize_t summary_show(struct usnic_ib_qp_grp *qp_grp, char *buf) } } - len = sysfs_emit_at(buf, len, "\n"); + sysfs_emit_at(buf, len, "\n"); /* Overwrite the last trailing space */ return len; }
In commit e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs _show uses to sysfs_emit") I mistakenly used len = sysfs_emit_at to overwrite the last trailing space of potentially multiple entry output. The length of the last sysfs_emit_at call is 1 and it should instead be ignored. Do so. Fixes: e28bf1f03b01 ("RDMA: Convert various random sprintf sysfs _show uses to sysfs_emit") Reported-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Joe Perches <joe@perches.com> --- drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)