From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/3] message-waiting: add allocation checks
Date: Wed, 26 Jan 2011 16:51:19 -0600 [thread overview]
Message-ID: <4D40A567.5090907@gmail.com> (raw)
In-Reply-To: <1295613846-19309-2-git-send-email-Pekka.Pessi@nokia.com>
[-- Attachment #1: Type: text/plain, Size: 3538 bytes --]
Hi Pekka,
On 01/21/2011 06:44 AM, Pekka.Pessi(a)nokia.com wrote:
> From: Pekka Pessi <Pekka.Pessi@nokia.com>
>
> ---
> src/message-waiting.c | 45 ++++++++++++++++++++++++++++++---------------
> 1 files changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/src/message-waiting.c b/src/message-waiting.c
> index 0e376b6..5d1126b 100644
> --- a/src/message-waiting.c
> +++ b/src/message-waiting.c
> @@ -179,20 +179,22 @@ static DBusMessage *set_cphs_mbdn(struct ofono_message_waiting *mw,
>
> if ((mw->ef_cphs_mbdn_length && !mw_mailbox_to_cphs_record[mailbox]) ||
> mw->cphs_mbdn_not_provided == TRUE) {
> - if (msg)
> + if (msg != NULL)
Please send this as a separate style patch
> return __ofono_error_not_supported(msg);
>
> return NULL;
> }
>
> if (mw->ef_cphs_mbdn_length == 0) {
> - if (msg)
> + if (msg != NULL)
ditto
> return __ofono_error_sim_not_ready(msg);
>
> return NULL;
> }
>
> req = g_new0(struct mbdn_set_request, 1);
> + if (req == NULL)
> + goto error;
You don't actually need to perform a NULL check here. g_new0 will never
return a NULL. Only g_try_new0 will.
>
> req->mw = mw;
> req->mailbox = mailbox;
> @@ -206,13 +208,17 @@ static DBusMessage *set_cphs_mbdn(struct ofono_message_waiting *mw,
> sync ? cphs_mbdn_sync_cb : mbdn_set_cb,
> OFONO_SIM_FILE_STRUCTURE_FIXED,
> mw_mailbox_to_cphs_record[mailbox],
> - efmbdn, mw->ef_cphs_mbdn_length, req) == -1) {
> - g_free(req);
> + efmbdn, mw->ef_cphs_mbdn_length, req) == -1)
> + goto error;
>
> - if (msg)
> - return __ofono_error_failed(msg);
> - } else
> - req->msg = msg ? dbus_message_ref(msg) : NULL;
> + req->msg = msg ? dbus_message_ref(msg) : NULL;
> + return NULL;
> +
> +error:
> + g_free(req);
> +
> + if (msg != NULL)
> + return __ofono_error_failed(msg);
>
> return NULL;
> }
> @@ -292,6 +298,8 @@ static DBusMessage *set_mbdn(struct ofono_message_waiting *mw, int mailbox,
> }
>
> req = g_new0(struct mbdn_set_request, 1);
> + if (req == NULL)
> + goto error;
Same comment as above
>
> req->mw = mw;
> req->mailbox = mailbox;
> @@ -303,13 +311,17 @@ static DBusMessage *set_mbdn(struct ofono_message_waiting *mw, int mailbox,
> if (ofono_sim_write(req->mw->sim, SIM_EFMBDN_FILEID, mbdn_set_cb,
> OFONO_SIM_FILE_STRUCTURE_FIXED,
> req->mw->efmbdn_record_id[mailbox],
> - efmbdn, req->mw->efmbdn_length, req) == -1) {
> - g_free(req);
> + efmbdn, req->mw->efmbdn_length, req) == -1)
> + goto error;
>
> - if (msg)
> - return __ofono_error_failed(msg);
> - } else
> - req->msg = msg ? dbus_message_ref(msg) : NULL;
> + req->msg = msg ? dbus_message_ref(msg) : NULL;
> + return NULL;
> +
> +error:
> + g_free(req);
> +
> + if (msg)
> + return __ofono_error_failed(msg);
>
> return NULL;
> }
> @@ -990,13 +1002,16 @@ struct ofono_message_waiting *ofono_message_waiting_create(struct ofono_modem *m
> struct ofono_message_waiting *mw;
>
> mw = g_try_new0(struct ofono_message_waiting, 1);
> -
Please send this along with the style patch...
> if (mw == NULL)
> return NULL;
>
> mw->atom = __ofono_modem_add_atom(modem,
> OFONO_ATOM_TYPE_MESSAGE_WAITING,
> mw_remove, mw);
> + if (mw->atom == NULL) {
> + g_free(mw);
> + return NULL;
> + }
This chunk is not necessary since add_atom does not use g_try_new...
>
> return mw;
> }
Regards,
-Denis
next prev parent reply other threads:[~2011-01-26 22:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-21 12:44 [PATCH 1/3] message-waiting: check for NULL argument Pekka.Pessi
2011-01-21 12:44 ` [PATCH 2/3] message-waiting: add allocation checks Pekka.Pessi
2011-01-21 12:44 ` [PATCH 3/3] doc: fix a kill-yank error Pekka.Pessi
2011-01-21 12:56 ` Marcel Holtmann
2011-01-26 22:51 ` Denis Kenzior [this message]
2011-01-26 22:47 ` [PATCH 1/3] message-waiting: check for NULL argument Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D40A567.5090907@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.