diff --git a/drivers/misc/rpmsgdev_server.c b/drivers/misc/rpmsgdev_server.c index 57bcc5a60a..d3595a7fe0 100644 --- a/drivers/misc/rpmsgdev_server.c +++ b/drivers/misc/rpmsgdev_server.c @@ -66,6 +66,7 @@ struct rpmsgdev_server_s * operation */ struct work_s work; /* Poll notify work */ + FAR void *priv; }; struct rpmsgdev_export_s @@ -454,6 +455,12 @@ static void rpmsgdev_ept_release(FAR struct rpmsg_endpoint *ept) nxmutex_unlock(&server->lock); + if (server->priv) + { + kmm_free(server->priv); + server->priv = NULL; + } + kmm_free(server); } @@ -476,6 +483,7 @@ static void rpmsgdev_ns_bind(FAR struct rpmsg_device *rdev, list_initialize(&server->head); nxmutex_init(&server->lock); + server->priv = priv; server->ept.priv = server; server->ept.release_cb = rpmsgdev_ept_release; @@ -518,14 +526,13 @@ static void rpmsgdev_server_created(FAR struct rpmsg_device *rdev, { snprintf(buf, sizeof(buf), "%s%s", RPMSGDEV_NAME_PREFIX, priv->localpath); - rpmsgdev_ns_bind(rdev, NULL, buf, RPMSG_ADDR_ANY); + rpmsgdev_ns_bind(rdev, priv, buf, RPMSG_ADDR_ANY); rpmsg_unregister_callback(priv, rpmsgdev_server_created, NULL, NULL, NULL); - kmm_free(priv); } }