Skip to content

Commit

Permalink
NTB: fix access of free-ed pointer
Browse files Browse the repository at this point in the history
We were accessing nt->mw_vec after freeing it. Fix the error path so
that we free nt->mw_vec after we have finished using it.

Signed-off-by: Sudip Mukherjee <[email protected]>
Signed-off-by: Jon Mason <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and jonmason committed Nov 8, 2015
1 parent 04afde4 commit d4adee0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/ntb/ntb_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
GFP_KERNEL, node);
if (!nt->qp_vec) {
rc = -ENOMEM;
goto err2;
goto err1;
}

if (nt_debugfs_dir) {
Expand All @@ -1092,38 +1092,37 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
for (i = 0; i < qp_count; i++) {
rc = ntb_transport_init_queue(nt, i);
if (rc)
goto err3;
goto err2;
}

INIT_DELAYED_WORK(&nt->link_work, ntb_transport_link_work);
INIT_WORK(&nt->link_cleanup, ntb_transport_link_cleanup_work);

rc = ntb_set_ctx(ndev, nt, &ntb_transport_ops);
if (rc)
goto err3;
goto err2;

INIT_LIST_HEAD(&nt->client_devs);
rc = ntb_bus_init(nt);
if (rc)
goto err4;
goto err3;

nt->link_is_up = false;
ntb_link_enable(ndev, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
ntb_link_event(ndev);

return 0;

err4:
ntb_clear_ctx(ndev);
err3:
kfree(nt->qp_vec);
ntb_clear_ctx(ndev);
err2:
kfree(nt->mw_vec);
kfree(nt->qp_vec);
err1:
while (i--) {
mw = &nt->mw_vec[i];
iounmap(mw->vbase);
}
kfree(nt->mw_vec);
err:
kfree(nt);
return rc;
Expand Down

0 comments on commit d4adee0

Please sign in to comment.