Skip to content

Commit 964e8be

Browse files
arnopoandersson
authored andcommitted
rpmsg: char: Return an error if device already open
The rpmsg_create_ept function is invoked when the device is opened. As only one endpoint must be created per device. It is not possible to open the same device twice. But there is nothing to prevent multi open. Return -EBUSY when device is already opened to have a generic error instead of relying on the back-end to potentially detect the error. Without this patch for instance the GLINK driver return -EBUSY while the virtio bus return -ENOSPC. Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20210311140413.31725-7-arnaud.pouliquen@foss.st.com Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
1 parent c486682 commit 964e8be

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/rpmsg/rpmsg_char.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
127127
struct rpmsg_device *rpdev = eptdev->rpdev;
128128
struct device *dev = &eptdev->dev;
129129

130+
if (eptdev->ept)
131+
return -EBUSY;
132+
130133
get_device(dev);
131134

132135
ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo);

0 commit comments

Comments
 (0)