Browse Source

rpmsg: rpc: fix ept memory leak during recovery

The rpmsg-rpc driver exposes a character device for each remote
service (a rpmsg-rpc device) providing a bunch of remote execution
functions. An endpoint is created in the open() fops, and forms the
source end-point of a dedicated communication channel to allow an
application to send and receive remote function execution commands/
responses on this service. This endpoint address is a child of the
parent virtio device to which the rpmsg-rpc device belongs to. The
virtio devices are deleted and recreated during a remoteproc crash
and recovery process. The associated child endpoints are not deleted
at present during recovery, and the corresponding release() cannot
delete the end-points if it happens after a recovery as the parent
rpmsg-rpc device has already been removed, thereby resulting in a
memory leak during recovery amidst an active usage.

Fix this by deleting all the epts associated with the parent virtio
device of the corresponding rpmsg-rpc device. This is done during the
rpmsg-rpc driver's .remove() which is invoked during the deletion of
the virtio device.

Signed-off-by: Suman Anna <s-anna@ti.com>
Suman Anna 11 years ago
parent
commit
3802adf983
1 changed files with 4 additions and 0 deletions
  1. 4 0
      drivers/rpmsg/rpmsg_rpc.c

+ 4 - 0
drivers/rpmsg/rpmsg_rpc.c

@@ -1319,6 +1319,10 @@ static void rppc_remove(struct rpmsg_device *rpdev)
 		if (rpc->state == RPPC_STATE_CONNECTED && rpc->in_transition)
 			complete_all(&rpc->reply_arrived);
 		rpc->state = RPPC_STATE_STALE;
+		if (rpc->ept) {
+			rpmsg_destroy_ept(rpc->ept);
+			rpc->ept = NULL;
+		}
 		wake_up_interruptible(&rpc->readq);
 	}
 	device_destroy(rppc_class, MKDEV(major, rppcdev->minor));