Skip to content

Commit

Permalink
misc: fastrpc: Don't reference rpmsg_device after remove
Browse files Browse the repository at this point in the history
As fastrpc_rpmsg_remove() returns the rpdev of the channel context is no
longer a valid object, so ensure to update the channel context to no
longer reference the old object and guard in the invoke code path
against dereferencing it.

Signed-off-by: Bjorn Andersson <[email protected]>
Signed-off-by: Mayank Chopra <[email protected]>
Signed-off-by: Abhinav Asati <[email protected]>
Signed-off-by: Vamsi Singamsetty <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
andersson authored and gregkh committed Sep 4, 2019
1 parent 278d56f commit 2e36987
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel,
if (!fl->sctx)
return -EINVAL;

if (!fl->cctx->rpdev)
return -EPIPE;

ctx = fastrpc_context_alloc(fl, kernel, sc, args);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
Expand Down Expand Up @@ -1495,6 +1498,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
misc_deregister(&cctx->miscdev);
of_platform_depopulate(&rpdev->dev);

cctx->rpdev = NULL;
fastrpc_channel_ctx_put(cctx);
}

Expand Down

0 comments on commit 2e36987

Please sign in to comment.