]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev
authorMatthias Kaehlcke <mka@chromium.org>
Mon, 10 Jan 2022 18:47:37 +0000 (10:47 -0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Thu, 3 Feb 2022 09:28:50 +0000 (10:28 +0100)
commitf7d44503920cbec64b6b390187af6e40b2e9f298
treed570e181acbe50a2b78edffeef4ab14d440429f9
parent00ba7f654005a790d79de926fb54652e15207ebc
rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev

BugLink: https://bugs.launchpad.net/bugs/1959879
commit 7a534ae89e34e9b51acb5a63dd0f88308178b46a upstream.

struct rpmsg_eptdev contains a struct cdev. The current code frees
the rpmsg_eptdev struct in rpmsg_eptdev_destroy(), but the cdev is
a managed object, therefore its release is not predictable and the
rpmsg_eptdev could be freed before the cdev is entirely released.

The cdev_device_add/del() API was created to address this issue
(see commit '233ed09d7fda ("chardev: add helper function to register
char devs with a struct device")'), use it instead of cdev add/del().

Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface")
Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220110104706.v6.2.Idde68b05b88d4a2e6e54766c653f3a6d9e419ce6@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/rpmsg/rpmsg_char.c