IB/mthca: Return proper error codes from mthca_fmr_alloc()

If the allocation of the MTT or the mailbox failed, mthca_fmr_alloc()
would return 0 (success) no matter what. This leads to crashes a
little down the road, when we try to dereference eg mr->mtt, which was
really ERR_PTR(-Ewhatever).

Signed-off-by: Olaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Olaf Kirch and committed by Roland Dreier 2c788534 f33afc26

+6 -2
+6 -2
drivers/infiniband/hw/mthca/mthca_mr.c
··· 613 613 sizeof *(mr->mem.tavor.mpt) * idx; 614 614 615 615 mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy); 616 - if (IS_ERR(mr->mtt)) 616 + if (IS_ERR(mr->mtt)) { 617 + err = PTR_ERR(mr->mtt); 617 618 goto err_out_table; 619 + } 618 620 619 621 mtt_seg = mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE; 620 622 ··· 629 627 mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg; 630 628 631 629 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); 632 - if (IS_ERR(mailbox)) 630 + if (IS_ERR(mailbox)) { 631 + err = PTR_ERR(mailbox); 633 632 goto err_out_free_mtt; 633 + } 634 634 635 635 mpt_entry = mailbox->buf; 636 636