From c2e83f15a6e6308a2959db10e9f81c81cfa88621 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 30 Dec 2020 17:31:44 +0100 Subject: [PATCH] manager: improve error checking in modem_reset() --- src/manager.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/manager.c b/src/manager.c index 17e58b2..423cbfa 100644 --- a/src/manager.c +++ b/src/manager.c @@ -121,7 +121,7 @@ static gboolean modem_reset_done(struct EG25Manager* manager) void modem_reset(struct EG25Manager *manager) { - int fd, ret, len = strlen(manager->modem_usb_id); + int fd, ret, len; if (manager->reset_timer) return; @@ -131,6 +131,13 @@ void modem_reset(struct EG25Manager *manager) manager->suspend_timer = 0; } + if (!manager->modem_usb_id) { + g_warning("Unknown modem USB ID"); + goto error; + } + + len = strlen(manager->modem_usb_id); + manager->modem_state = EG25_STATE_RESETTING; fd = open("/sys/bus/usb/drivers/usb/unbind", O_WRONLY);