IB/mthca: Fix memory leaks in error handling

Fix memory leaks in mthca_create_qp() and mthca_create_srq()
error handling.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Jack Morgenstein and committed by Roland Dreier 17e2e819 59f174fa

+7 -3
+7 -3
drivers/infiniband/hw/mthca/mthca_provider.c
··· 445 445 if (pd->uobject) { 446 446 context = to_mucontext(pd->uobject->context); 447 447 448 - if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 449 - return ERR_PTR(-EFAULT); 448 + if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { 449 + err = -EFAULT; 450 + goto err_free; 451 + } 450 452 451 453 err = mthca_map_user_db(to_mdev(pd->device), &context->uar, 452 454 context->db_tab, ucmd.db_index, ··· 524 522 if (pd->uobject) { 525 523 context = to_mucontext(pd->uobject->context); 526 524 527 - if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) 525 + if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) { 526 + kfree(qp); 528 527 return ERR_PTR(-EFAULT); 528 + } 529 529 530 530 err = mthca_map_user_db(to_mdev(pd->device), &context->uar, 531 531 context->db_tab,