linux-stable/drivers/rpmsg
Shengjiu Wang ef828a39d6 rpmsg: char: Avoid double destroy of default endpoint
commit 467233a4ac upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-24 09:56:58 +02:00
..
Kconfig
Makefile
mtk_rpmsg.c
qcom_glink_native.c rpmsg: qcom: glink: replace strncpy() with strscpy_pad() 2022-10-12 09:51:25 +02:00
qcom_glink_native.h
qcom_glink_rpm.c
qcom_glink_smem.c
qcom_glink_ssr.c
qcom_smd.c rpmsg: qcom: glink: replace strncpy() with strscpy_pad() 2022-10-12 09:51:25 +02:00
rpmsg_char.c rpmsg: char: Avoid double destroy of default endpoint 2022-10-24 09:56:58 +02:00
rpmsg_char.h
rpmsg_core.c rpmsg: Fix possible refcount leak in rpmsg_register_device_override() 2022-08-17 15:15:47 +02:00
rpmsg_ctrl.c
rpmsg_internal.h
rpmsg_ns.c
virtio_rpmsg_bus.c