aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2014-03-28 04:23:07 -0400
committerRoland Dreier <roland@purestorage.com>2014-04-01 13:53:29 -0400
commit4661bd798f1b58ee2755bfa04003638345802680 (patch)
treea657827350791f971ac0c5a4e4e5a9dfbc5444dc /drivers/infiniband
parent3839d8ac1bac55922f6632e36040fdc0de374bba (diff)
mlx4_core: Make buffer larger to avoid overflow warning
My static checker complains that the sprintf() here can overflow. drivers/infiniband/hw/mlx4/main.c:1836 mlx4_ib_alloc_eqs() error: format string overflow. buf_size: 32 length: 69 This seems like a valid complaint. The "dev->pdev->bus->name" string can be 48 characters long. I just made the buffer 80 characters instead of 69 and I changed the sprintf() to snprintf(). Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/mlx4/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 6eb0d442a805..20b4d7a2d3d7 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1803,7 +1803,7 @@ static void init_pkeys(struct mlx4_ib_dev *ibdev)
1803 1803
1804static void mlx4_ib_alloc_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev) 1804static void mlx4_ib_alloc_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev)
1805{ 1805{
1806 char name[32]; 1806 char name[80];
1807 int eq_per_port = 0; 1807 int eq_per_port = 0;
1808 int added_eqs = 0; 1808 int added_eqs = 0;
1809 int total_eqs = 0; 1809 int total_eqs = 0;
@@ -1833,8 +1833,8 @@ static void mlx4_ib_alloc_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev)
1833 eq = 0; 1833 eq = 0;
1834 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB) { 1834 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB) {
1835 for (j = 0; j < eq_per_port; j++) { 1835 for (j = 0; j < eq_per_port; j++) {
1836 sprintf(name, "mlx4-ib-%d-%d@%s", 1836 snprintf(name, sizeof(name), "mlx4-ib-%d-%d@%s",
1837 i, j, dev->pdev->bus->name); 1837 i, j, dev->pdev->bus->name);
1838 /* Set IRQ for specific name (per ring) */ 1838 /* Set IRQ for specific name (per ring) */
1839 if (mlx4_assign_eq(dev, name, NULL, 1839 if (mlx4_assign_eq(dev, name, NULL,
1840 &ibdev->eq_table[eq])) { 1840 &ibdev->eq_table[eq])) {