aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rpmsg.h
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2012-06-07 08:39:35 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2012-07-04 04:51:59 -0400
commit15fd943af50dbc5f7f4de33835795c72595f7bf4 (patch)
treeb35e37da3edf0b0166f14cf1d71e665d506b7fdf /include/linux/rpmsg.h
parent5a081caa0414b9bbb82c17ffab9d6fe66edbb72f (diff)
rpmsg: make sure inflight messages don't invoke just-removed callbacks
When inbound messages arrive, rpmsg core looks up their associated endpoint (by destination address) and then invokes their callback. We've made sure that endpoints will never be de-allocated after they were found by rpmsg core, but we also need to protect against the (rare) scenario where the rpmsg driver was just removed, and its callback function isn't available anymore. This is achieved by introducing a callback mutex, which must be taken before the callback is invoked, and, obviously, before it is removed. Cc: stable <stable@vger.kernel.org> Reported-by: Fernando Guzman Lugo <fernando.lugo@ti.com> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'include/linux/rpmsg.h')
-rw-r--r--include/linux/rpmsg.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h
index 195f373590b8..82a673905edb 100644
--- a/include/linux/rpmsg.h
+++ b/include/linux/rpmsg.h
@@ -39,6 +39,7 @@
39#include <linux/device.h> 39#include <linux/device.h>
40#include <linux/mod_devicetable.h> 40#include <linux/mod_devicetable.h>
41#include <linux/kref.h> 41#include <linux/kref.h>
42#include <linux/mutex.h>
42 43
43/* The feature bitmap for virtio rpmsg */ 44/* The feature bitmap for virtio rpmsg */
44#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ 45#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
@@ -123,6 +124,7 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, u32);
123 * @rpdev: rpmsg channel device 124 * @rpdev: rpmsg channel device
124 * @refcount: when this drops to zero, the ept is deallocated 125 * @refcount: when this drops to zero, the ept is deallocated
125 * @cb: rx callback handler 126 * @cb: rx callback handler
127 * @cb_lock: must be taken before accessing/changing @cb
126 * @addr: local rpmsg address 128 * @addr: local rpmsg address
127 * @priv: private data for the driver's use 129 * @priv: private data for the driver's use
128 * 130 *
@@ -144,6 +146,7 @@ struct rpmsg_endpoint {
144 struct rpmsg_channel *rpdev; 146 struct rpmsg_channel *rpdev;
145 struct kref refcount; 147 struct kref refcount;
146 rpmsg_rx_cb_t cb; 148 rpmsg_rx_cb_t cb;
149 struct mutex cb_lock;
147 u32 addr; 150 u32 addr;
148 void *priv; 151 void *priv;
149}; 152};