Commit Graph
3199 Commits
Author SHA1 Message Date
Aleksander Morgado eb64d39e52 kernel-device: assert 'vendor' and 'product' in get_device_ids()
These two parameters must always be given.
2017-08-15 18:18:45 +02:00
Ben Chan 7e22696b34 kernel-device: expect non-NULL 'vendor' and 'product' argument in get_device_ids()
get_device_ids() in mm-kernel-device-udev.c accepts a NULL 'vendor' or
'product' argument, but the current implementation could result in a
potential NULL dereferences of the 'vendor' argument. Given that
get_device_ids() is a local helper and its only caller provides a
non-NULL 'vendor' and 'product' argument, this patch removes the NULL
checks (i.e. get_device_ids() expects non-NULL 'vendor' and 'product').

This patch also rearranges the code such that the 'vendor' argument is
updated only when the function returns TRUE, just like how the 'product'
argument is handled.
2017-08-15 18:15:53 +02:00
Ben Chan 7ae32d6c61 charset: fix mm_charset_get_encoded_len
The while loop in mm_charset_get_encoded_len() iterates through each
valid UTF-8 encoded character in the given NULL-terminated UTF-8 string.
It uses g_utf8_find_next_char() to find the position of the next
character. In case, g_utf8_find_next_char() returns NULL, it tries to
find the end (i.e. the NULL character) of the string.

This patch fixes the following issues in the while loop:

1. The loop uses both 'next' and 'end' to track the position of the next
   character in the string.

   When g_utf8_find_next_char() returns a non-NULL value, 'next' is
   essentially the same as 'end'.

   When g_utf8_find_next_char() returns NULL, 'next' remains NULL while
   'end' is adjusted to track the end of the string (but is done
   incorrectly as described in #2). After the 'p = next' assignment, the
   'while (*p)' check results in a NULL dereference. 'p' should thus be
   set to 'end' instead of 'next'.

   'next' is thus redundant and can be removed.

2. When g_utf8_find_next_char() returns NULL and 'end' is adjusted to
   track the end of string, the 'while (*end++)' loop stops when finding
   the NULL character, but 'end' is advanced past the NULL character.
   After the 'p = end' assignment, the 'while (*p)' check results in a
   dereference of out-of-bounds pointer.

   'while (*++end)' should be used instead given that 'p' doesn't point
   to a NULL character when 'end = p' happens. 'end' will be updated to
   point to the NULL character. After the 'p = end' assignment (fixed in
   #1), the 'while (*p)' check will properly stop the loop.
2017-08-15 09:37:24 +02:00
Aleksander Morgado d7d2c320d3 broadband-modem-mbim: explicitly remove notification handler on unref
When we remove the last object reference, make sure the notification
handler is also removed, or we may end up using an already freed
object.

https://retrace.fedoraproject.org/faf/reports/1815001/
2017-08-12 00:57:34 +02:00
Ben Chan 36e7cd50ce plugin: fix forbidden_product_strings check in apply_post_probing_filters
This patch fixes a bug in apply_post_probing_filters() where it iterates
through `self->priv->forbidden_product_strings' but incorrectly accesses
`self->priv->product_strings[i]' inside the loop.
`self->priv->forbidden_product_strings[i]' should be accessed instead.
2017-08-11 17:09:18 -05:00
Aleksander Morgado dec53d6ef6 modem-helpers: allow unquoted strings in +CCLK responses
Also:
  * define the leading '+' as a escaped value
  * allow any number of spaces between '+CCLK' and the string value.
2017-08-09 21:59:31 +02:00
Aleksander Morgado 9528450684 bearer-mbim: stop trying to reload stats on OperationNotAllowed
The Sierra Wireless EM7345 reports OperationNotAllowed when trying to
load stats, just cancel stats reloading if so.

    ModemManager[8318]: [/dev/cdc-wdm1] Received message (translated)...
    >>>>>> Header:
    >>>>>>   length      = 48
    >>>>>>   type        = command-done (0x80000003)
    >>>>>>   transaction = 24
    >>>>>> Fragment header:
    >>>>>>   total   = 1
    >>>>>>   current = 0
    >>>>>> Contents:
    >>>>>>   status error = 'OperationNotAllowed' (0x0000001c)
    >>>>>>   service      = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)
    >>>>>>   cid          = 'packet-statistics' (0x00000014)
2017-08-09 12:04:59 +02:00
Ben Chan 05a1097a27 iface-modem: remove unnecessary error check
This patch removes an unnecessary error check in the
update_unlock_retries() where the error is never set.
2017-08-08 09:23:55 +02:00
Aleksander Morgado 75036a4658 bearer-mbim: refactor disconnect_set_ready()
Try to make it more clear which are the different branches in the
logic, and jump out as soon as the branch is finished.
2017-08-06 13:18:15 +02:00
Aleksander Morgado e51ee31d50 broadband-bearer: run init sequence after flashing in disconnection
The init-sequence configured for the TTY that is being used as data
port must not be launched during the port reopen() sequence; instead
we must run it manually after the port flashing has finished.
2017-08-04 19:47:45 +02:00
Ben Chan 5828435b46 port-probe: remove unused variable 2017-08-04 15:17:31 +02:00
Ben Chan f7eca732f9 sim-qmi: remove unused variables 2017-08-04 15:17:31 +02:00
Ben Chan 941a41d30f broadband-modem: ensure `match_info' is always initialized
This patch initializes `match_info' in registration_status_check_ready()
to NULL by default, such that `match_info' is always initialized even if
`self->priv->modem_3gpp_registration_regex' contains no elements.
Though `self->priv->modem_3gpp_registration_regex' always contains some
elements in the current implementation, it's better not to rely on that.
2017-08-04 15:15:41 +02:00
Ben Chan 24ed8d3e99 broadband-modem: fix an ineffective `g_assert (equip_id)'
This patch fixes an ineffective `g_assert (equip_id)' in
modem_load_equipment_identifier_finish(). After mm_parse_gsn() succeeds,
`equip_id' is freed but not reset to NULL, so `g_assert (equip_id)' will
never assert even if `imei', `meid', and `esn' are all NULL (though that
shouldn't happen when mm_parse_gsn() succeeds).
2017-08-04 15:00:27 +02:00
Ben Chan 0d3cca2c6f broadband-modem-qmi: fix potential use-after-freed issues
This patch fixes some potential use-after-freed issues in
dms_get_ids_ready(). When an invalid ESN / MEID is retrieved,
`ctx->self->priv->esn' / `ctx->self->priv->meid' is freed but not reset
to NULL. If no IMEI is retrieved, `str' can be set to the already freed
`ctx->self->priv->esn' / `ctx->self->priv->meid' and then propagated to
a GSimpleAsyncResult object.
2017-08-04 14:08:18 +02:00
Aleksander Morgado f81a518515 bearer-mbim: minor update in debug log messages 2017-08-04 13:49:32 +02:00
Ben Chan d58305bf1f bearer-mbim: avoid accessing invalid session_id and nw_error
This patch fixes an issue in disconnect_set_ready(). If
mbim_message_connect_response_parse(), `session_id' and `nw_error' are
not set to a valid value, and thus shouldn't be used.
2017-08-04 13:41:26 +02:00
Ben Chan 0bb01ab68d sms-part-cdma: add missing break statements in cause_code_to_delivery_state
This patch fixes cause_code_to_delivery_state() by adding two missing
break statements for the case ERROR_CLASS_TEMPORARY and
ERROR_CLASS_PERMANENT in the `switch (error_class)` statement. Without
the break statements, the switch always falls through to the default and
returns MM_SMS_DELIVERY_STATE_UNKNOWN for an `error_class' of value
ERROR_CLASS_TEMPORARY or ERROR_CLASS_PERMANENT.
2017-08-03 12:19:37 +02:00
Ben Chan 03bf0479ae plugin-manager: remove unused variable 2017-08-03 12:19:37 +02:00
Ben Chan 838173d50f call-list: remove unused variables 2017-08-03 12:19:37 +02:00
Ben Chan 06bbe67000 broadband-modem: remove unused variables 2017-08-03 12:19:37 +02:00
Ben Chan 8e645485e3 broadband-bearer: remove unused variable 2017-08-03 12:19:37 +02:00
Ben Chan ae82e7d58c broadband-modem-mbim: remove unused variable 2017-08-03 12:18:59 +02:00
Aleksander Morgado 60092ed7ea broadband-modem: single g_object_get() call to read multiple properties 2017-08-01 10:11:02 +02:00
Carlo Lobrano 9cdc237241 sim hot swap: improved error management
Currently, when SIM hot swap fails in either mm-iface or plugin, the
ModemManager still opens ports context and prints a message saying that
SIM hot swap is supported and that it's waiting for SIM insertion,
instead of clearly saying that SIM hot swap is not working.

This patch:

1. introduces a new property MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED
   which is FALSE by default and set to TRUE only when
   setup_sim_hot_swap_finish() succeded.
2. subordinates the completion of SIM hot swap setup (in
   mm-broadband-modem) and the related messages to the the value of
   MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED

Finally, this patch replaces the MBIM's sim_hot_swap_on private property
with the new property MM_IFACE_MODEM_SIM_HOT_SWAP_CONFIGURED, since they have the
same meaning.
2017-08-01 10:02:01 +02:00
Ben Chan 4e468d04ac bearer-mbim: avoid calling mbim_message_unref on NULL MbimMessage 2017-07-27 10:18:48 +02:00
Ben Chan 3f273429a5 broadband-bearer: port initable_init_async to use GTask 2017-07-19 07:08:21 -07:00
Ben Chan 6dc2f23d8f broadband-bearer: port disconnect_{3gpp,cdma} to use GTask 2017-07-19 07:08:20 -07:00
Ben Chan fd34814b36 broadband-bearer: port disconnect to use GTask 2017-07-19 07:08:00 -07:00
Ben Chan 903e228782 broadband-bearer: port connect_{3gpp,cdma} to use GTask 2017-07-19 07:04:40 -07:00
Ben Chan be2ac3f256 broadband-bearer: port connect to use GTask 2017-07-19 07:04:40 -07:00
Ben Chan e356137484 broadband-bearer: port dial_3gpp to use GTask 2017-07-19 07:04:40 -07:00
Ben Chan 8af44d3589 broadband-bearer: fix crm_range_ready
crm_range_ready() misses a return statement after it invokes
interface_initialization_step(), which will lead to an invalid access of
the already freed InitAsyncContext.
2017-07-19 13:56:34 +02:00
Aleksander Morgado 4db3ccf2af helpers: +CNUM parser doesn't return any error 2017-07-19 11:21:27 +02:00
Aleksander Morgado 7ff5e30dce broadband-modem: if no own numbers returned, complete task with NULL
Fixes: 738deebfb4

Reported-by: Colin Helliwell <colin.helliwell@ln-systems.com>
2017-07-19 11:18:11 +02:00
Aleksander Morgado 14dbbad1ad broadband-modem: plug memleak in init_current_storages()
==28664== 4 bytes in 1 blocks are definitely lost in loss record 33 of 4,317
    ==28664==    at 0x4C2BE1F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28664==    by 0x4C2E164: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28664==    by 0x644E0CF: g_realloc (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6469C06: ??? (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6469C61: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x4E8514A: mm_common_build_sms_storages_string (mm-common-helpers.c:116)
    ==28664==    by 0x489035: cpms_query_ready (mm-broadband-modem.c:5428)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
    ==28664==    by 0x44EADF: at_command_ready (mm-base-modem-at.c:503)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
    ==28664==    by 0x4D8122: serial_command_ready (mm-port-serial-at.c:392)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
    ==28664==
    ==28664== 4 bytes in 1 blocks are definitely lost in loss record 34 of 4,317
    ==28664==    at 0x4C2BE1F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28664==    by 0x4C2E164: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28664==    by 0x644E0CF: g_realloc (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6469C06: ??? (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6469C61: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x4E8514A: mm_common_build_sms_storages_string (mm-common-helpers.c:116)
    ==28664==    by 0x489067: cpms_query_ready (mm-broadband-modem.c:5430)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
    ==28664==    by 0x44EADF: at_command_ready (mm-base-modem-at.c:503)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
    ==28664==    by 0x4D8122: serial_command_ready (mm-port-serial-at.c:392)
    ==28664==    by 0x5E8E335: g_simple_async_result_complete (in /usr/lib/libgio-2.0.so.0.5200.2)
2017-07-18 11:31:36 +02:00
Aleksander Morgado bad79cb5e1 port-serial: plug memleak on error processing
==28664== 216 (120 direct, 96 indirect) bytes in 5 blocks are definitely lost in loss record 4,109 of 4,317
    ==28664==    at 0x4C2BEEF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28664==    by 0x644E018: g_malloc (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6465B05: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6469C32: g_string_sized_new (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x4D7861: parse_response (mm-port-serial-at.c:142)
    ==28664==    by 0x4D3B52: parse_response_buffer (mm-port-serial.c:857)
    ==28664==    by 0x4D40F2: common_input_available (mm-port-serial.c:981)
    ==28664==    by 0x4D41B4: iochannel_input_available (mm-port-serial.c:1004)
    ==28664==    by 0x64488B4: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6448C77: ??? (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x6448F91: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5200.2)
    ==28664==    by 0x438035: main (main.c:180)
2017-07-18 11:28:33 +02:00
Aleksander Morgado fa31b699ec broadband-modem: remove unneeded InitializationStartedContext struct 2017-07-18 10:53:03 +02:00
Ben Chan 6515c81f44 broadband-modem: port modem_3gpp_cleanup_unsolicited_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 81d2d572b4 broadband-modem: port modem_3gpp_setup_unsolicited_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 0c49fb3e2f broadband-modem: port modem_voice_{setup,cleanup}_unsolicited_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 4a2cc7b731 broadband-modem: port modem_messaging_{setup,cleanup}_unsolicited_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan c7e47b97e8 broadband-modem: port modem_cdma_get_detailed_registration_state to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan e040ee27a0 broadband-modem: port modem_cdma_get_service_status to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 610a6299e1 broadband-modem: port modem_3gpp_run_registration_checks to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan a93add611f broadband-modem: port modem_3gpp_load_enabled_facility_locks to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 1fe33d34e8 broadband-modem: port modem_3gpp_load_subscription_state to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan c812101a12 broadband-modem: port modem_3gpp_{enable,disable}_unsolicited_registration_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan ece9b87a67 broadband-modem: port modem_3gpp_setup_unsolicited_registration_events to use GTask 2017-07-18 10:42:17 +02:00
Ben Chan 7ee52bb99a broadband-modem: port modem_3gpp_cleanup_unsolicited_registration_events to use GTask 2017-07-18 10:42:17 +02:00