From ba49cb81f13274078e7b6b3eb6dec8f90e4818e3 Mon Sep 17 00:00:00 2001 From: Benedikt Schmidt Date: Thu, 21 Sep 2023 09:37:47 +0200 Subject: [PATCH] drivers: modem: fix thread function signatures Fix thread function signatures to avoid stack corruption on thread exit. Signed-off-by: Benedikt Schmidt --- drivers/modem/gsm_ppp.c | 8 ++++++-- drivers/modem/hl7800.c | 8 ++++++-- drivers/modem/quectel-bg9x.c | 8 ++++++-- drivers/modem/simcom-sim7080.c | 8 ++++++-- drivers/modem/ublox-sara-r4.c | 8 ++++++-- drivers/modem/wncm14a2a.c | 8 ++++++-- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/modem/gsm_ppp.c b/drivers/modem/gsm_ppp.c index 34eb0bbb55..154092ac35 100644 --- a/drivers/modem/gsm_ppp.c +++ b/drivers/modem/gsm_ppp.c @@ -169,8 +169,12 @@ static int modem_atoi(const char *s, const int err_value, } #endif -static void gsm_rx(struct gsm_modem *gsm) +static void gsm_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p2); + ARG_UNUSED(p3); + + struct gsm_modem *gsm = p1; LOG_DBG("starting"); while (true) { @@ -1323,7 +1327,7 @@ static int gsm_init(const struct device *dev) (void)k_thread_create(&gsm->rx_thread, gsm_rx_stack, K_KERNEL_STACK_SIZEOF(gsm_rx_stack), - (k_thread_entry_t) gsm_rx, + gsm_rx, gsm, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); (void)k_thread_name_set(&gsm->rx_thread, "gsm_rx"); diff --git a/drivers/modem/hl7800.c b/drivers/modem/hl7800.c index 291856a01f..c635016197 100644 --- a/drivers/modem/hl7800.c +++ b/drivers/modem/hl7800.c @@ -4482,8 +4482,12 @@ static void process_fw_update_rx(struct net_buf **rx_buf) #endif /* CONFIG_MODEM_HL7800_FW_UPDATE */ /* RX thread */ -static void hl7800_rx(void) +static void hl7800_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + struct net_buf *rx_buf = NULL; struct net_buf *frag = NULL; int i, cmp_res; @@ -6426,7 +6430,7 @@ static int hl7800_init(const struct device *dev) k_thread_name_set( k_thread_create(&hl7800_rx_thread, hl7800_rx_stack, K_THREAD_STACK_SIZEOF(hl7800_rx_stack), - (k_thread_entry_t)hl7800_rx, NULL, NULL, NULL, + hl7800_rx, NULL, NULL, NULL, RX_THREAD_PRIORITY, 0, K_NO_WAIT), "hl7800 rx"); diff --git a/drivers/modem/quectel-bg9x.c b/drivers/modem/quectel-bg9x.c index 04bb08d665..714a7606ab 100644 --- a/drivers/modem/quectel-bg9x.c +++ b/drivers/modem/quectel-bg9x.c @@ -846,8 +846,12 @@ static ssize_t offload_sendmsg(void *obj, const struct msghdr *msg, int flags) /* Func: modem_rx * Desc: Thread to process all messages received from the Modem. */ -static void modem_rx(void) +static void modem_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + while (true) { /* Wait for incoming data */ @@ -1264,7 +1268,7 @@ static int modem_init(const struct device *dev) /* start RX thread */ k_thread_create(&modem_rx_thread, modem_rx_stack, K_KERNEL_STACK_SIZEOF(modem_rx_stack), - (k_thread_entry_t) modem_rx, + modem_rx, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); /* Init RSSI query */ diff --git a/drivers/modem/simcom-sim7080.c b/drivers/modem/simcom-sim7080.c index 39fb66b6aa..b6a159e519 100644 --- a/drivers/modem/simcom-sim7080.c +++ b/drivers/modem/simcom-sim7080.c @@ -802,8 +802,12 @@ static int offload_socket(int family, int type, int proto) /* * Process all messages received from the modem. */ -static void modem_rx(void) +static void modem_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + while (true) { /* Wait for incoming data */ modem_iface_uart_rx_wait(&mctx.iface, K_FOREVER); @@ -2414,7 +2418,7 @@ static int modem_init(const struct device *dev) } k_thread_create(&modem_rx_thread, modem_rx_stack, K_KERNEL_STACK_SIZEOF(modem_rx_stack), - (k_thread_entry_t)modem_rx, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); + modem_rx, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); /* Init RSSI query */ k_work_init_delayable(&mdata.rssi_query_work, modem_rssi_query_work); diff --git a/drivers/modem/ublox-sara-r4.c b/drivers/modem/ublox-sara-r4.c index ca70b1465e..a3fe3c45f8 100644 --- a/drivers/modem/ublox-sara-r4.c +++ b/drivers/modem/ublox-sara-r4.c @@ -936,8 +936,12 @@ MODEM_CMD_DEFINE(on_cmd_socknotifycreg) } /* RX thread */ -static void modem_rx(void) +static void modem_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + while (true) { /* wait for incoming data */ modem_iface_uart_rx_wait(&mctx.iface, K_FOREVER); @@ -2220,7 +2224,7 @@ static int modem_init(const struct device *dev) /* start RX thread */ k_thread_create(&modem_rx_thread, modem_rx_stack, K_KERNEL_STACK_SIZEOF(modem_rx_stack), - (k_thread_entry_t) modem_rx, + modem_rx, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); #if defined(CONFIG_MODEM_UBLOX_SARA_RSSI_WORK) diff --git a/drivers/modem/wncm14a2a.c b/drivers/modem/wncm14a2a.c index 520c431258..5b60d0aaff 100644 --- a/drivers/modem/wncm14a2a.c +++ b/drivers/modem/wncm14a2a.c @@ -1057,8 +1057,12 @@ static void wncm14a2a_read_rx(struct net_buf **buf) } /* RX thread */ -static void wncm14a2a_rx(void) +static void wncm14a2a_rx(void *p1, void *p2, void *p3) { + ARG_UNUSED(p1); + ARG_UNUSED(p2); + ARG_UNUSED(p3); + struct net_buf *rx_buf = NULL; struct net_buf *frag = NULL; int i; @@ -1430,7 +1434,7 @@ static int wncm14a2a_init(const struct device *dev) /* start RX thread */ k_thread_create(&wncm14a2a_rx_thread, wncm14a2a_rx_stack, K_KERNEL_STACK_SIZEOF(wncm14a2a_rx_stack), - (k_thread_entry_t) wncm14a2a_rx, + wncm14a2a_rx, NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT); /* init RSSI query */