linux-stable/drivers/infiniband/hw/mlx4
Christophe JAILLET 7e47a8419d IB/mlx4: Fix the size of a buffer in add_port_entries()
commit d7f393430a upstream.

In order to be sure that 'buff' is never truncated, its size should be
12, not 11.

When building with W=1, this fixes the following warnings:

  drivers/infiniband/hw/mlx4/sysfs.c: In function ‘add_port_entries’:
  drivers/infiniband/hw/mlx4/sysfs.c:268:34: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
    268 |                 sprintf(buff, "%d", i);
        |                                  ^
  drivers/infiniband/hw/mlx4/sysfs.c:268:17: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 11
    268 |                 sprintf(buff, "%d", i);
        |                 ^~~~~~~~~~~~~~~~~~~~~~
  drivers/infiniband/hw/mlx4/sysfs.c:286:34: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
    286 |                 sprintf(buff, "%d", i);
        |                                  ^
  drivers/infiniband/hw/mlx4/sysfs.c:286:17: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 11
    286 |                 sprintf(buff, "%d", i);
        |                 ^~~~~~~~~~~~~~~~~~~~~~

Fixes: c1e7e46612 ("IB/mlx4: Add iov directory in sysfs under the ib device")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0bb1443eb47308bc9be30232cc23004c4d4cf43e.1695448530.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-10 22:00:44 +02:00
..
ah.c
alias_GUID.c RDMA/mlx4: Delete useless module.h include 2022-01-28 13:03:12 -04:00
cm.c RDMA/mlx4: Avoid flush_scheduled_work() usage 2022-05-20 11:21:00 -03:00
cq.c RDMA/mlx4: Remove unused parameter udata 2021-05-20 11:52:17 -03:00
doorbell.c RDMA: Use the sg_table directly and remove the opencoded version from umem 2021-08-24 19:52:40 -03:00
Kconfig
mad.c treewide: use get_random_u32() when possible 2022-10-11 17:42:58 -06:00
main.c RDMA/mlx4: Avoid flush_scheduled_work() usage 2022-05-20 11:21:00 -03:00
Makefile
mcg.c
mlx4_ib.h RDMA/mlx4: Avoid flush_scheduled_work() usage 2022-05-20 11:21:00 -03:00
mr.c IB: Set IOVA/LENGTH on IB_MR in core/uverbs layers 2022-09-22 12:46:39 +03:00
qp.c RDMA/mlx4: Make check for invalid flags stricter 2023-08-03 10:24:02 +02:00
srq.c RDMA/mlx4: remove redundant assignment to variable nreq 2022-02-01 10:55:43 -04:00
sysfs.c IB/mlx4: Fix the size of a buffer in add_port_entries() 2023-10-10 22:00:44 +02:00