From c9bc6b1ad5540ea74ad740f0074459d2a3670c52 Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 22 Aug 2023 15:41:07 +0800 Subject: [PATCH] rpmsg socket: add return value check. Signed-off-by: ligd --- net/rpmsg/rpmsg_sockif.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index 2880ef6d9c..19b7e19c59 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -228,6 +228,7 @@ static inline void rpmsg_socket_poll_notify( static FAR struct rpmsg_socket_conn_s *rpmsg_socket_alloc(void) { FAR struct rpmsg_socket_conn_s *conn; + int ret; conn = kmm_zalloc(sizeof(struct rpmsg_socket_conn_s)); if (!conn) @@ -235,7 +236,12 @@ static FAR struct rpmsg_socket_conn_s *rpmsg_socket_alloc(void) return NULL; } - circbuf_init(&conn->recvbuf, NULL, 0); + ret = circbuf_init(&conn->recvbuf, NULL, 0); + if (ret < 0) + { + kmm_free(conn); + return NULL; + } nxmutex_init(&conn->polllock); nxmutex_init(&conn->sendlock);