linux/drivers/rpmsg
Shengjiu Wang 467233a4ac rpmsg: char: Avoid double destroy of default endpoint
The rpmsg_dev_remove() in rpmsg_core is the place for releasing
this default endpoint.

So need to avoid destroying the default endpoint in
rpmsg_chrdev_eptdev_destroy(), this should be the same as
rpmsg_eptdev_release(). Otherwise there will be double destroy
issue that ept->refcount report warning:

refcount_t: underflow; use-after-free.

Call trace:
 refcount_warn_saturate+0xf8/0x150
 virtio_rpmsg_destroy_ept+0xd4/0xec
 rpmsg_dev_remove+0x60/0x70

The issue can be reproduced by stopping remoteproc before
closing the /dev/rpmsgX.

Fixes: bea9b79c2d ("rpmsg: char: Add possibility to use default endpoint of the rpmsg device")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/1663725523-6514-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
2022-09-21 11:21:33 -06:00
..
Kconfig rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl 2022-03-13 11:49:53 -05:00
Makefile rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl 2022-03-13 11:49:53 -05:00
mtk_rpmsg.c rpmsg: mtk_rpmsg: Fix circular locking dependency 2022-06-14 16:41:10 -06:00
qcom_glink_native.c rpmsg: convert sysfs snprintf to sysfs_emit 2022-07-16 23:08:47 -05:00
qcom_glink_native.h rpmsg: glink: Switch to SPDX license identifier 2018-06-03 17:37:15 -07:00
qcom_glink_rpm.c rpmsg: glink: Switch to SPDX license identifier 2018-06-03 17:37:15 -07:00
qcom_glink_smem.c rpmsg: glink: Set tail pointer to 0 at end of FIFO 2019-10-11 11:34:12 -07:00
qcom_glink_ssr.c rpmsg: qcom: correct kerneldoc 2022-07-16 22:13:32 -05:00
qcom_smd.c rpmsg: qcom_smd: Fix refcount leak in qcom_smd_parse_edge 2022-07-16 22:15:40 -05:00
rpmsg_char.c rpmsg: char: Avoid double destroy of default endpoint 2022-09-21 11:21:33 -06:00
rpmsg_char.h rpmsg: char: Export eptdev create and destroy functions 2022-03-13 11:49:53 -05:00
rpmsg_core.c rpmsg: Strcpy is not safe, use strscpy_pad() instead 2022-06-24 11:37:00 -06:00
rpmsg_ctrl.c rpmsg: ctrl: Introduce new RPMSG_CREATE/RELEASE_DEV_IOCTL controls 2022-03-13 11:49:53 -05:00
rpmsg_internal.h rpmsg: Fix parameter naming for announce_create/destroy ops 2022-06-24 10:58:12 -06:00
rpmsg_ns.c rpmsg: Fix calling device_lock() on non-initialized device 2022-05-06 09:51:33 +02:00
virtio_rpmsg_bus.c rpmsg: virtio: Fix the unregistration of the device rpmsg_ctrl 2022-04-26 09:27:15 -06:00