mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-28 23:03:24 +02:00
manager: modem_reset: fix file descriptor leek
fd wasn't being closed if the write failed. Theoretically if a system with an unstable modem ran for long enough, this could bring down eg25-manager.
This commit is contained in:
@@ -226,24 +226,26 @@ gboolean modem_reset(struct EG25Manager *manager)
|
||||
g_warning("Unable to open /sys/bus/usb/drivers/usb/unbind");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = write(fd, manager->modem_usb_id, len);
|
||||
close(fd);
|
||||
if (ret < len) {
|
||||
g_warning("Couldn't unbind modem: wrote %d/%d bytes", ret, len);
|
||||
goto error;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
fd = open("/sys/bus/usb/drivers/usb/bind", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
g_warning("Unable to open /sys/bus/usb/drivers/usb/unbind");
|
||||
g_warning("Unable to open /sys/bus/usb/drivers/usb/bind");
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = write(fd, manager->modem_usb_id, len);
|
||||
close(fd);
|
||||
if (ret < len) {
|
||||
g_warning("Couldn't bind modem: wrote %d/%d bytes", ret, len);
|
||||
goto error;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
g_message("Successfully reset modem's USB connection");
|
||||
|
||||
|
Reference in New Issue
Block a user