diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2012-02-09 15:16:41 +0200 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-02-28 19:09:54 +0200 |
commit | fa2d7795b2e859574c86cf186e488d12178d51b3 (patch) | |
tree | af37a844c4531936e0236ead5d6a2ce80686d208 /drivers/rpmsg | |
parent | 9cd8eb433cbd440b25d4080b5add998da21fdb9c (diff) |
rpmsg: fix name service endpoint leak
The name service endpoint wasn't destroyed, so fix it.
This is achieved by introducing an internal __rpmsg_destroy_ept
function which doesn't assume the given ept is bound to an rpmsg
channel (much like the existing __rpmsg_create_ept).
This is needed because the name service ept belongs to the rpmsg bus,
and is never bound with a specific rpdev.
Reported-by: Omar Ramirez Luna <omar.ramirez@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Mark Grosen <mgrosen@ti.com>
Cc: Suman Anna <s-anna@ti.com>
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Cc: Rob Clark <rob@ti.com>
Cc: Ludovic BARRE <ludovic.barre@stericsson.com>
Cc: Loic PALLARDY <loic.pallardy@stericsson.com>
Cc: Omar Ramirez Luna <omar.ramirez@ti.com>
Diffstat (limited to 'drivers/rpmsg')
-rw-r--r-- | drivers/rpmsg/virtio_rpmsg_bus.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 8980ac2cc546..4db9cf8754a0 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -290,22 +290,36 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rpdev, EXPORT_SYMBOL(rpmsg_create_ept); /** - * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint + * __rpmsg_destroy_ept() - destroy an existing rpmsg endpoint + * @vrp: virtproc which owns this ept * @ept: endpoing to destroy * - * Should be used by drivers to destroy an rpmsg endpoint previously - * created with rpmsg_create_ept(). + * An internal function which destroy an ept without assuming it is + * bound to an rpmsg channel. This is needed for handling the internal + * name service endpoint, which isn't bound to an rpmsg channel. + * See also __rpmsg_create_ept(). */ -void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) +static void +__rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept) { - struct virtproc_info *vrp = ept->rpdev->vrp; - mutex_lock(&vrp->endpoints_lock); idr_remove(&vrp->endpoints, ept->addr); mutex_unlock(&vrp->endpoints_lock); kfree(ept); } + +/** + * rpmsg_destroy_ept() - destroy an existing rpmsg endpoint + * @ept: endpoing to destroy + * + * Should be used by drivers to destroy an rpmsg endpoint previously + * created with rpmsg_create_ept(). + */ +void rpmsg_destroy_ept(struct rpmsg_endpoint *ept) +{ + __rpmsg_destroy_ept(ept->rpdev->vrp, ept); +} EXPORT_SYMBOL(rpmsg_destroy_ept); /* @@ -964,6 +978,9 @@ static void __devexit rpmsg_remove(struct virtio_device *vdev) if (ret) dev_warn(&vdev->dev, "can't remove rpmsg device: %d\n", ret); + if (vrp->ns_ept) + __rpmsg_destroy_ept(vrp, vrp->ns_ept); + idr_remove_all(&vrp->endpoints); idr_destroy(&vrp->endpoints); |