Skip to content

Commit 4d09d8d

Browse files
committed
Merge branch 'mlx4-fixes'
Tariq Toukan says: ==================== mlx4_core misc fixes This patchset by Jack contains misc fixes to the mlx4 Core driver. Patch 1 fixes a use-after-free situation by marking (nullifying) the pointer, please queue for -stable >= v4.0. Patch 2 adds a missing lock acquire and release in SRIOV command interface, please queue for -stable >= v4.9. Patch 3 avoids calling roundup_pow_of_two when argument is zero, please queue for -stable >= v3.3. Series generated against net commit: a3b1933 Merge tag 'mlx5-fixes-2019-03-11' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents c7fce56 + 8511a65 commit 4d09d8d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

drivers/net/ethernet/mellanox/mlx4/cmd.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
26452645
if (!priv->cmd.context)
26462646
return -ENOMEM;
26472647

2648+
if (mlx4_is_mfunc(dev))
2649+
mutex_lock(&priv->cmd.slave_cmd_mutex);
26482650
down_write(&priv->cmd.switch_sem);
26492651
for (i = 0; i < priv->cmd.max_cmds; ++i) {
26502652
priv->cmd.context[i].token = i;
@@ -2670,6 +2672,8 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
26702672
down(&priv->cmd.poll_sem);
26712673
priv->cmd.use_events = 1;
26722674
up_write(&priv->cmd.switch_sem);
2675+
if (mlx4_is_mfunc(dev))
2676+
mutex_unlock(&priv->cmd.slave_cmd_mutex);
26732677

26742678
return err;
26752679
}
@@ -2682,16 +2686,21 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
26822686
struct mlx4_priv *priv = mlx4_priv(dev);
26832687
int i;
26842688

2689+
if (mlx4_is_mfunc(dev))
2690+
mutex_lock(&priv->cmd.slave_cmd_mutex);
26852691
down_write(&priv->cmd.switch_sem);
26862692
priv->cmd.use_events = 0;
26872693

26882694
for (i = 0; i < priv->cmd.max_cmds; ++i)
26892695
down(&priv->cmd.event_sem);
26902696

26912697
kfree(priv->cmd.context);
2698+
priv->cmd.context = NULL;
26922699

26932700
up(&priv->cmd.poll_sem);
26942701
up_write(&priv->cmd.switch_sem);
2702+
if (mlx4_is_mfunc(dev))
2703+
mutex_unlock(&priv->cmd.slave_cmd_mutex);
26952704
}
26962705

26972706
struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,13 +2719,13 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc)
27192719
int total_pages;
27202720
int total_mem;
27212721
int page_offset = (be32_to_cpu(qpc->params2) >> 6) & 0x3f;
2722+
int tot;
27222723

27232724
sq_size = 1 << (log_sq_size + log_sq_sride + 4);
27242725
rq_size = (srq|rss|xrc) ? 0 : (1 << (log_rq_size + log_rq_stride + 4));
27252726
total_mem = sq_size + rq_size;
2726-
total_pages =
2727-
roundup_pow_of_two((total_mem + (page_offset << 6)) >>
2728-
page_shift);
2727+
tot = (total_mem + (page_offset << 6)) >> page_shift;
2728+
total_pages = !tot ? 1 : roundup_pow_of_two(tot);
27292729

27302730
return total_pages;
27312731
}

0 commit comments

Comments
 (0)