Skip to content

Commit

Permalink
rpmsg: return fail if either source or destination address is zero
Browse files Browse the repository at this point in the history
to help detect rpmsg_send is called before the endpoint
initialization or after the endpoint uninitialization

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 committed Apr 23, 2020
1 parent fdda485 commit 41f4f4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
*/
static inline unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
{
return (ept->dest_addr != RPMSG_ADDR_ANY) &&
(ept->addr != RPMSG_ADDR_ANY);
return ept && ept->rdev && ept->dest_addr && ept->dest_addr != RPMSG_ADDR_ANY;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
{
struct rpmsg_device *rdev;

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

rdev = ept->rdev;
Expand Down

0 comments on commit 41f4f4a

Please sign in to comment.