Re: [PATCH v2] rpmsg: char: Drop messages that arrive while the device is closed
From: Mathieu Poirier
Date: Fri Dec 04 2026 - 10:18:33 EST
On Fri, Dec 04, 2026 at 07:04:11AM +0300, Chrispine Tinega wrote:
> Hi Mathieu,
>
> On Thu, Dec 03, 2026 at 11:24:48AM -0600, Mathieu Poirier wrote:
> > > + if (eptdev->default_ept && !eptdev->ept) {
> >
> > Is there a point in checking @eptdev->default at all? From what I understand,
> > checking @eptdev->ept should be sufficient.
> >
> > Otherwise I'm good with your patch.
>
> For a non-default endpoint, rpmsg_eptdev_open() calls rpmsg_create_ept()
> and only assigns eptdev->ept after it returns. A transport can invoke
> rpmsg_ept_cb() inside that window while eptdev->ept is still NULL.
>
Right, and in that case messages should be dropped.
> For example, qcom_smd_create_ept() -> qcom_smd_channel_open() installs
> the callback and moves the channel to SMD_CHANNEL_OPENED before sleeping
> for the remote state. If the remote side opens and sends an initial
> message, qcom_smd_channel_intr() runs rpmsg_ept_cb() in IRQ context
> before rpmsg_eptdev_open() wakes up to set eptdev->ept.
> virtio_rpmsg_create_ept() also registers the endpoint in vrp->endpoints
> before returning.
>
Again, we agree. In either cases messages should be dropped until ->ept is
valid. I don't see a point in checking for ->default_ept. What am I missing?
> Checking !eptdev->ept unconditionally would drop those initial messages
> on a newly opened non-default endpoint. On release, non-default
> endpoints are already torn down by rpmsg_destroy_ept(), so only
> eptdev->default_ept needs this guard.
>
> Let me know if you want a brief comment noting that in rpmsg_ept_cb() in
> a v3, or if v2 is fine as is.
>
> Regards,
> Chrispine