diff mbox series

[v2,7/7] rpmsg: char: Return error if user tries to destroy a default endpoint.

Message ID 20210413134458.17912-8-arnaud.pouliquen@foss.st.com (mailing list archive)
State Superseded
Headers show
Series Restructure the rpmsg char and introduce the rpmsg-raw channel | expand

Commit Message

Arnaud Pouliquen April 13, 2021, 1:44 p.m. UTC
Using the RPMSG_DESTROY_EPT_IOCTL control, user application can
destroy an endpoint. This patch prevents to destroy a default endpoint
associated to a channel.

This update is needed to manage the "rpmsg-raw" channel. In this
case a default endpoint is used and destroying it without the
channel does not make sense.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
 drivers/rpmsg/rpmsg_char.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series


diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index fa59abfa8878..d4316bb904f2 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -280,6 +280,10 @@  static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd,
 		return -EINVAL;
+	/* Don't allow to destroy a default endpoint. */
+	if (!eptdev->rpdev || eptdev->ept == eptdev->rpdev->ept)
+		return -EPERM;
 	return rpmsg_chrdev_destroy_eptdev(&eptdev->dev, NULL);