Commit Graph

46 Commits

Author SHA1 Message Date
Denis Kenzior 765c6655f2 treewide: Use L_TFR macro 2019-05-24 11:55:38 -05:00
Jonas Bonn 3beeff758d treewide: Remove superfluous use of _GNU_SOURCE
There are a large number of files in the tree that define _GNU_SOURCE
despite not actually using features hidden behind this flag.  This patch
removes all these definitions in one fell swoop...
2018-10-17 10:01:57 -05:00
Denis Kenzior 8b8a760644 simfs: Fix crash in sim_fs_op_free
If an operation is in progress and an operation is canceled, we don't
actually destroy it, but simply clear out the callback.  In the case of
a context being destroyed, the operation is left on the simfs op_q with
a dangling pointer to the already freed context.  So the current logic
in sim_fs_op_free tries to access invalid memory.

Fix this by performing the watch operations in sim_fs_end_current
instead and setting the context pointer appropriately.
2018-03-29 09:46:22 -05:00
Denis Kenzior a99c0be535 simfs: Fix crash
0  0x00007ffff7b20517 in g_queue_is_empty () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
1  0x00005555556adcdd in sim_fs_op_free (pointer=0x5555559cb990) at src/simfs.c:101
2  0x00007ffff7b205fc in g_queue_foreach () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
3  0x00007ffff7b2065b in g_queue_free_full () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
4  0x00005555556add81 in sim_fs_free (fs=0x5555559c0780) at src/simfs.c:125
5  0x00005555556828f3 in sim_remove (atom=0x5555559cb000) at src/sim.c:3175
6  0x000055555564f16f in flush_atoms (modem=0x555555a8fb00, new_state=MODEM_STATE_POWER_OFF) at src/modem.c:432
7  0x000055555564f3bd in modem_change_state (modem=0x555555a8fb00, new_state=MODEM_STATE_POWER_OFF)
    at src/modem.c:510
8  0x000055555564ff99 in set_powered (modem=0x555555a8fb00, powered=0) at src/modem.c:896
9  0x000055555565074c in modem_set_property (conn=0x55555596c8d0, msg=0x55555596e460, data=0x555555a8fb00)
    at src/modem.c:1120
2018-03-19 11:50:13 -05:00
James Prestwood f972ba88f1 simfs: read files from specific AID's
The simfs atom could not read EF's that did not exist on the
'default' ADF directory. This implements a new way to read EF's
that exist on a given AID. A new fs object/context can be
initialized for a given AID. Using this fs context with
the existing read file API will read from that AID rather than
the default ADF.
2017-11-06 16:12:19 -06:00
Slava Monich 440c9bec88 simfs: Prevent a crash in sim_fs_notify_file_watches
If no file watchers have ever been added, context->file_watches
is NULL and sim_fs_notify_file_watches() should take that into
account.
2017-05-12 14:37:26 -05:00
John Ernberg 74e85341ce simfs: Remove explicit casts 2016-04-22 15:41:27 -05:00
Denis Kenzior 6eb9542907 simfs: Handle optional EF paths 2012-11-23 07:22:25 -06:00
Denis Kenzior 5de557bc55 simfs: Update to the new SIM api 2012-11-22 10:26:34 -06:00
Guillaume Zajac 7852f25079 simfs: Call callback even if impl isn't provided 2011-11-27 06:03:14 -06:00
Marcel Holtmann 7e6afe37bf core: Update copyright information 2011-10-10 13:39:42 -07:00
Denis Kenzior 652f2963ae simfs: Fix error reported by valgrind
==20365== Invalid read of size 8
==20365==    at 0x4B3501: sim_fs_free (simfs.c:114)
==20365==    by 0x493CEC: sim_remove (sim.c:2485)
==20365==    by 0x4703D7: modem_change_state (modem.c:410)
==20365==    by 0x470664: set_powered (modem.c:848)
==20365==    by 0x4706BA: __ofono_modem_shutdown (modem.c:2137)
==20365==    by 0x46F2C5: signal_cb (main.c:76)
==20365==    by 0x52F555E: g_io_unix_dispatch (giounix.c:166)
==20365==    by 0x52A0AAB: g_main_dispatch (gmain.c:2440)
==20365==    by 0x52A203B: g_main_context_dispatch (gmain.c:3013)
==20365==    by 0x52A2501: g_main_context_iterate (gmain.c:3091)
==20365==    by 0x52A2C98: g_main_loop_run (gmain.c:3299)
==20365==    by 0x46F0D3: main (main.c:243)
==20365==  Address 0x63ff998 is 8 bytes inside a block of size 16 free'd
==20365==    at 0x4C2612D: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20365==    by 0x52AA4A1: g_free (gmem.c:263)
==20365==    by 0x52C433D: g_slice_free1 (gslice.c:907)
==20365==    by 0x52C58D0: g_slist_free_1 (gslist.c:192)
==20365==    by 0x52C5C5F: g_slist_remove (gslist.c:465)
==20365==    by 0x4B342A: sim_fs_context_free (simfs.c:192)
==20365==    by 0x4B3500: sim_fs_free (simfs.c:117)
==20365==    by 0x493CEC: sim_remove (sim.c:2485)
==20365==    by 0x4703D7: modem_change_state (modem.c:410)
==20365==    by 0x470664: set_powered (modem.c:848)
==20365==    by 0x4706BA: __ofono_modem_shutdown (modem.c:2137)
==20365==    by 0x46F2C5: signal_cb (main.c:76)
2011-05-11 12:29:59 -05:00
Denis Kenzior 993acd4132 simfs: Fix issue reported by valgrind
==20287== Invalid read of size 4
==20287==    at 0x52B5C6B: g_queue_peek_nth_link (gqueue.c:704)
==20287==    by 0x52B5F57: g_queue_peek_nth (gqueue.c:848)
==20287==    by 0x4B33ED: sim_fs_context_free (simfs.c:170)
==20287==    by 0x4B34F8: sim_fs_free (simfs.c:116)
==20287==    by 0x493CEC: sim_remove (sim.c:2485)
==20287==    by 0x4703D7: modem_change_state (modem.c:410)
==20287==    by 0x470664: set_powered (modem.c:848)
==20287==    by 0x4706BA: __ofono_modem_shutdown (modem.c:2137)
==20287==    by 0x46F2C5: signal_cb (main.c:76)
==20287==    by 0x52F555E: g_io_unix_dispatch (giounix.c:166)
==20287==    by 0x52A0AAB: g_main_dispatch (gmain.c:2440)
==20287==    by 0x52A203B: g_main_context_dispatch (gmain.c:3013)
==20287==  Address 0x63fae70 is 16 bytes inside a block of size 24
free'd
==20287==    at 0x4C2612D: free (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20287==    by 0x52AA4A1: g_free (gmem.c:263)
==20287==    by 0x52C433D: g_slice_free1 (gslice.c:907)
==20287==    by 0x52B4E96: g_queue_free (gqueue.c:60)
==20287==    by 0x4B34E0: sim_fs_free (simfs.c:107)
==20287==    by 0x493CEC: sim_remove (sim.c:2485)
==20287==    by 0x4703D7: modem_change_state (modem.c:410)
==20287==    by 0x470664: set_powered (modem.c:848)
==20287==    by 0x4706BA: __ofono_modem_shutdown (modem.c:2137)
==20287==    by 0x46F2C5: signal_cb (main.c:76)
==20287==    by 0x52F555E: g_io_unix_dispatch (giounix.c:166)
==20287==    by 0x52A0AAB: g_main_dispatch (gmain.c:2440)
2011-05-11 12:20:59 -05:00
Guillaume Lucas 4ff9cf9a27 simfs: fix GLib-CRITICAL warning
During modem release, when there is no SIM card, a GLib-CRITICAL
issue occurs during the free of the sim fs context.
2011-03-11 14:57:31 -06:00
Denis Kenzior 50c3d98ff3 simfs: Fix leaking of the voicecall context
When we're shutting down all atoms are removed and the voicecall context
does not have a chance to be freed.  Make sure simfs frees it.
2011-02-10 00:27:01 -06:00
Denis Kenzior b97399ce12 simfs: Add function to notify all file watches 2011-02-07 13:35:41 -06:00
Denis Kenzior 417b445eaf simfs: Add file changed watches to simfs contexts 2011-02-07 12:25:46 -06:00
Andrzej Zaborowski a7a0cb1ed0 simfs: implement ofono_sim_context api 2011-02-03 13:13:37 -06:00
Andrzej Zaborowski 0cde90ff8e simfs: Use cache for sim_fs_read_info requests too.
There seems to be no reason that the fileinfo is cached for file
read or block read requests but not info_only requests, so move
code around to fix this.  O_RDWR is changed to O_WRONLY for the
cache file because the file is not being read in case of cache miss.
2011-02-03 11:01:40 -06:00
Aki Niemi 6ed9fe85a5 simfs: Add NULL check 2011-02-02 11:03:21 +02:00
Andrzej Zaborowski f2c73f0a52 simfs: Return from sim_fs_op_check_cached on error 2011-01-29 18:39:37 +01:00
Andrzej Zaborowski 882c0c2761 simfs: Reset op_source in simfs_read_block
If the block is not in cache or if this is the last block of a last
op in the queue, then fs->op_source might be left with the wrong
value.
2011-01-29 18:39:37 +01:00
Andrzej Zaborowski 2cec48fb1c simfs: Add cache flushing functions 2011-01-12 14:07:09 -06:00
Jeevaka Badrappan d06c03f099 simfs: Add unknown sim phase check 2010-12-12 04:41:27 -06:00
Lucas De Marchi 7484d799c9 simfs: explicitly compare pointers to NULL
This patch was generated by the following semantic patch
(http://coccinelle.lip6.fr/)

// <smpl>
@fix disable is_null,isnt_null1@
expression *E;
@@

- !E
+ E == NULL
// </smpl>
2010-11-29 13:09:50 -06:00
Jeevaka Badrappan b4353d15ea simfs: coding style fixes - rule M6 2010-11-22 05:06:21 -06:00
Jeevaka Badrappan 9bebe654e3 simfs: Fix issue with sim_fs_op_error 2010-10-24 09:11:15 -05:00
Denis Kenzior 40904f655d simfs: Fix issue with check_cached
The only_info logic was inverted, causing us to always read from the
modem.
2010-10-22 12:11:26 -05:00
Denis Kenzior 71255c49fb simfs: Use errno for simfs errors 2010-10-22 11:45:39 -05:00
Denis Kenzior 6ce608b01d simfs: No need to set these variables 2010-10-22 11:42:40 -05:00
Petteri Tikander d74e0b5ece simfs: retrieve only EF-info without EF-contents 2010-10-22 11:13:46 -05:00
Denis Kenzior cfb3cd9647 simfs: Don't cache if phase is unknown 2010-10-19 14:07:41 -05:00
Denis Kenzior aa42d954ed simfs: Make compile 2010-10-15 06:26:28 -05:00
Denis Kenzior e828bc767c simfs: Also clean out image files
When cleaning cache
2010-10-13 05:04:47 -05:00
Denis Kenzior bd8c7e92bb simfs: Fix the number of bytes copied
In block reading operations we read too much when the number of bytes to
read is smaller than the size of the file.
2010-10-13 05:04:47 -05:00
Denis Kenzior e755292874 simfs: Add some debug statements 2010-10-13 05:04:47 -05:00
Denis Kenzior 9ed8beba77 simfs: Move buffer back to the op structure
This was causing problems when multiple sim writes were being issued
(and thus bug #8265).
2010-10-13 05:04:46 -05:00
Denis Kenzior 38fad92882 simfs: Group lines logically 2010-10-13 05:04:46 -05:00
Denis Kenzior 096634e798 simfs: If buffer alloc fails, error out 2010-10-13 05:04:46 -05:00
Denis Kenzior f4c66f67df simfs: Don't try to read image cache imsi is null 2010-10-13 05:04:46 -05:00
Denis Kenzior 413c200dfb simfs: Make image cache logic a bit easier to read 2010-10-13 05:04:46 -05:00
Kristen Carlson Accardi 19fcae699c simfs: cache images 2010-10-13 05:04:46 -05:00
Denis Kenzior 1bdf68e133 simfs: Fix freeing a NULL queue 2010-09-22 22:39:29 -05:00
Denis Kenzior 997269a773 simfs: Add sim_fs_check_version
Used to blow away older simfs versions
2010-09-09 08:50:29 -05:00
Denis Kenzior fc1e3a7da4 simfs: Simplify logic 2010-09-09 08:50:28 -05:00
Denis Kenzior 5754eaf7e9 sim: Break out sim file reading into simfs 2010-09-09 08:50:28 -05:00