• Ohad Ben-Cohen's avatar
    rpmsg: avoid premature deallocation of endpoints · 735129c4
    Ohad Ben-Cohen authored
    commit 5a081caa upstream.
    
    When an inbound message arrives, the rpmsg core looks up its
    associated endpoint and invokes the registered callback.
    
    If a message arrives while its endpoint is being removed (because
    the rpmsg driver was removed, or a recovery of a remote processor
    has kicked in) we must ensure atomicity, i.e.:
    
    - Either the ept is removed before it is found
    
    or
    
    - The ept is found but will not be freed until the callback returns
    
    This is achieved by maintaining a per-ept reference count, which,
    when drops to zero, will trigger deallocation of the ept.
    
    With this in hand, it is now forbidden to directly deallocate
    epts once they have been added to the endpoints idr.
    Reported-by: default avatarFernando Guzman Lugo <fernando.lugo@ti.com>
    Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    735129c4
virtio_rpmsg_bus.c 30.4 KB