Re: [PATCH 4/4] atmodem: sim-auth atom driver.
Hi Pekka, On 01/21/2011 11:07 AM, Pekka Pessi wrote: > Hi Denis, > > 2011/1/20 Denis Kenzior : >> My view is that checking mallocs of small structures is pretty much >> pointless on Linux. > > > The glib functions that ofono uses extensively don't do any malloc > checking, and it makes checking on the ofono side bit pointless. If > malloc fails, ofono will crash. If it has not get killed by oom > police. > Well the g_try_ series do allow you to recover from a bad malloc, which is what we generally use. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 4/4] atmodem: sim-auth atom driver.
Hi Denis, 2011/1/20 Denis Kenzior : > My view is that checking mallocs of small structures is pretty much > pointless on Linux. The glib functions that ofono uses extensively don't do any malloc checking, and it makes checking on the ofono side bit pointless. If malloc fails, ofono will crash. If it has not get killed by oom police. -- Pekka.Pessi mail at nokia.com ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 4/4] atmodem: sim-auth atom driver.
Hi Jeevaka, >> +buffer = g_malloc(len); > > missing check for buffer memory allocation failure > Actually he's using g_malloc, so the application will simply abort. >> +sad = g_new0(struct sim_auth_data, 1); > > missing check for "sad" memory allocation failure Same here. My view is that checking mallocs of small structures is pretty much pointless on Linux. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
Re: [PATCH 4/4] atmodem: sim-auth atom driver.
Hi Andrew, On 01/19/2011 02:07 AM, Andrzej Zaborowski wrote: > --- > Makefile.am|3 +- > drivers/atmodem/atmodem.c |2 + > drivers/atmodem/atmodem.h |3 + > drivers/atmodem/sim-auth.c | 162 > > 4 files changed, 169 insertions(+), 1 deletions(-) > create mode 100644 drivers/atmodem/sim-auth.c > Patch has been applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: [PATCH 4/4] atmodem: sim-auth atom driver.
Hi Andrzej, ofono-boun...@ofono.org wrote: > +static void at_discover_apps_cb(gboolean ok, GAtResult *result, > + gpointer user_data) +{ > + struct cb_data *cbd = user_data; > + GAtResultIter iter; > + ofono_sim_list_apps_cb_t cb = cbd->cb; > + struct ofono_error error; > + const unsigned char *dataobj; > + gint linelen; > + unsigned char *buffer; > + int len; > + > + decode_at_error(&error, g_at_result_final_response(result)); + > + if (!ok) { > + cb(&error, NULL, 0, cbd->data); > + return; > + } > + > + g_at_result_iter_init(&iter, result); > + > + len = 0; > + while (g_at_result_iter_next(&iter, "+CUAD:")) { > + if (!g_at_result_iter_next_hexstring(&iter, > NULL, &linelen)) > + goto error; > + > + len += linelen; > + } > + > + g_at_result_iter_init(&iter, result); > + > + buffer = g_malloc(len); > + len = 0; > + while (g_at_result_iter_next(&iter, "+CUAD:")) { > + g_at_result_iter_next_hexstring(&iter, > &dataobj, &linelen); > + memcpy(buffer + len, dataobj, linelen); > + len += linelen; > + } missing check for buffer memory allocation failure > + > +static int at_sim_auth_probe(struct ofono_sim_auth *sa, > unsigned int vendor, > + void *data) > +{ > + GAtChat *chat = data; > + struct sim_auth_data *sad; > + > + sad = g_new0(struct sim_auth_data, 1); > + sad->chat = g_at_chat_clone(chat); > + sad->vendor = vendor; missing check for "sad" memory allocation failure Regards, Jeevaka ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono