Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c788534 authored by Olaf Kirch's avatar Olaf Kirch Committed by Roland Dreier
Browse files

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: default avatarOlaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent f33afc26
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -613,8 +613,10 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
			sizeof *(mr->mem.tavor.mpt) * idx;
			sizeof *(mr->mem.tavor.mpt) * idx;


	mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy);
	mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy);
	if (IS_ERR(mr->mtt))
	if (IS_ERR(mr->mtt)) {
		err = PTR_ERR(mr->mtt);
		goto err_out_table;
		goto err_out_table;
	}


	mtt_seg = mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE;
	mtt_seg = mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE;


@@ -627,8 +629,10 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
		mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg;
		mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg;


	mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
	mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
	if (IS_ERR(mailbox))
	if (IS_ERR(mailbox)) {
		err = PTR_ERR(mailbox);
		goto err_out_free_mtt;
		goto err_out_free_mtt;
	}


	mpt_entry = mailbox->buf;
	mpt_entry = mailbox->buf;