mlx4: Fixing use after free

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>

authored by Yevgeny Petrilin and committed by David S. Miller 53020092 5e8996e7

+2 -1
+2 -1
drivers/net/mlx4/mcg.c
··· 469 469 470 470 /*remove from list of promisc qps */ 471 471 list_del(&pqp->list); 472 - kfree(pqp); 473 472 474 473 /* set the default entry not to include the removed one */ 475 474 mailbox = mlx4_alloc_cmd_mailbox(dev); ··· 527 528 out_list: 528 529 if (back_to_list) 529 530 list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]); 531 + else 532 + kfree(pqp); 530 533 out_mutex: 531 534 mutex_unlock(&priv->mcg_table.mutex); 532 535 return err;