Skip to content

Commit

Permalink
mlx4: Fixing use after free
Browse files Browse the repository at this point in the history
In case of allocation failure, tried to use the promiscuous QP
entry that was previously freed.
Now freeing this entry only in case we will not put it back to the list
of promiscuous entries.

Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yevgeny Petrilin authored and David S. Miller committed Mar 31, 2011
1 parent 5e8996e commit 5302009
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/mlx4/mcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 vep_num, u8 port,

/*remove from list of promisc qps */
list_del(&pqp->list);
kfree(pqp);

/* set the default entry not to include the removed one */
mailbox = mlx4_alloc_cmd_mailbox(dev);
Expand Down Expand Up @@ -528,6 +527,8 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 vep_num, u8 port,
out_list:
if (back_to_list)
list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]);
else
kfree(pqp);
out_mutex:
mutex_unlock(&priv->mcg_table.mutex);
return err;
Expand Down

0 comments on commit 5302009

Please sign in to comment.