Skip to content

Commit 4624840

Browse files
flamingradiangregkh
authored andcommitted
misc: fastrpc: reject new invocations during device removal
The channel's rpmsg object allows new invocations to be made. After old invocations are already interrupted, the driver shouldn't try to invoke anymore. Invalidating the rpmsg at the end of the driver removal function makes it easy to cause a race condition in userspace. Even closing a file descriptor before the driver finishes its cleanup can cause an invocation via fastrpc_release_current_dsp_process() and subsequent timeout. Invalidate the channel before the invocations are interrupted to make sure that no invocations can be created to hang after the device closes. Fixes: c68cfb7 ("misc: fastrpc: Add support for context Invoke method") Cc: stable <stable@kernel.org> Signed-off-by: Richard Acayan <mailingradian@gmail.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20230523152550.438363-5-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b6a0628 commit 4624840

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/misc/fastrpc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,9 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
23632363
struct fastrpc_user *user;
23642364
unsigned long flags;
23652365

2366+
/* No invocations past this point */
23662367
spin_lock_irqsave(&cctx->lock, flags);
2368+
cctx->rpdev = NULL;
23672369
list_for_each_entry(user, &cctx->users, user)
23682370
fastrpc_notify_users(user);
23692371
spin_unlock_irqrestore(&cctx->lock, flags);
@@ -2382,7 +2384,6 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev)
23822384

23832385
of_platform_depopulate(&rpdev->dev);
23842386

2385-
cctx->rpdev = NULL;
23862387
fastrpc_channel_ctx_put(cctx);
23872388
}
23882389

0 commit comments

Comments
 (0)