Skip to content

Commit 3eba159

Browse files
rpmsg: return fail if either source or destination address is zero
to help detect rpmsg_send is called before the endpoint initialization or after the endpoint uninitialization Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1 parent 2103a90 commit 3eba159

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/include/openamp/rpmsg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
146146
*/
147147
static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
148148
{
149-
return (ept->dest_addr != RPMSG_ADDR_ANY) &&
150-
(ept->addr != RPMSG_ADDR_ANY);
149+
return ept && ept->rdev && ept->dest_addr &&
150+
ept->dest_addr != RPMSG_ADDR_ANY;
151151
}
152152

153153
/**

lib/rpmsg/rpmsg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
115115
{
116116
struct rpmsg_device *rdev;
117117

118-
if (!ept || !ept->rdev || !data || dst == RPMSG_ADDR_ANY)
118+
if (!ept || !ept->rdev || !data || !dst || dst == RPMSG_ADDR_ANY)
119119
return RPMSG_ERR_PARAM;
120120

121121
rdev = ept->rdev;

0 commit comments

Comments
 (0)