* [PATCH 1/2] network.c: notify_status_watches: check for NULL
@ 2017-09-11 0:25 Alexander Couzens
2017-09-11 0:25 ` [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register() Alexander Couzens
2017-09-11 15:39 ` [PATCH 1/2] network.c: notify_status_watches: check for NULL Denis Kenzior
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Couzens @ 2017-09-11 0:25 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 644 bytes --]
In rare cases when ofono_netreg_status_notify() is called before
ofono_netreg_register() netreg->status_watches is NULL.
---
src/network.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/network.c b/src/network.c
index a3d41a74d555..6e69b078495f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1186,6 +1186,9 @@ static void notify_status_watches(struct ofono_netreg *netreg)
const char *mcc = NULL;
const char *mnc = NULL;
+ if (netreg->status_watches == NULL)
+ return;
+
if (netreg->current_operator) {
mcc = netreg->current_operator->mcc;
mnc = netreg->current_operator->mnc;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register()
2017-09-11 0:25 [PATCH 1/2] network.c: notify_status_watches: check for NULL Alexander Couzens
@ 2017-09-11 0:25 ` Alexander Couzens
2017-09-11 15:41 ` Denis Kenzior
2017-09-11 15:39 ` [PATCH 1/2] network.c: notify_status_watches: check for NULL Denis Kenzior
1 sibling, 1 reply; 4+ messages in thread
From: Alexander Couzens @ 2017-09-11 0:25 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1525 bytes --]
When registering callbacks before ofono_netreg_register(), callbacks
will use the netreg api which might lead into undefined behaviour,
because certain fields aren't yet initilized.
---
drivers/qmimodem/network-registration.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
index c88e80bdf711..70ddea52df40 100644
--- a/drivers/qmimodem/network-registration.c
+++ b/drivers/qmimodem/network-registration.c
@@ -511,10 +511,17 @@ static void event_notify(struct qmi_result *result, void *user_data)
static void set_event_cb(struct qmi_result *result, void *user_data)
{
struct ofono_netreg *netreg = user_data;
+ struct netreg_data *data = ofono_netreg_get_data(netreg);
DBG("");
ofono_netreg_register(netreg);
+
+ qmi_service_register(data->nas, QMI_NAS_EVENT,
+ event_notify, netreg, NULL);
+
+ qmi_service_register(data->nas, QMI_NAS_SS_INFO_IND,
+ ss_info_notify, netreg, NULL);
}
static void create_nas_cb(struct qmi_service *service, void *user_data)
@@ -536,12 +543,6 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
data->nas = qmi_service_ref(service);
- qmi_service_register(data->nas, QMI_NAS_EVENT,
- event_notify, netreg, NULL);
-
- qmi_service_register(data->nas, QMI_NAS_SS_INFO_IND,
- ss_info_notify, netreg, NULL);
-
param = qmi_param_new();
if (!param)
goto done;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] network.c: notify_status_watches: check for NULL
2017-09-11 0:25 [PATCH 1/2] network.c: notify_status_watches: check for NULL Alexander Couzens
2017-09-11 0:25 ` [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register() Alexander Couzens
@ 2017-09-11 15:39 ` Denis Kenzior
1 sibling, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2017-09-11 15:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
Hi Alexander,
On 09/10/2017 07:25 PM, Alexander Couzens wrote:
> In rare cases when ofono_netreg_status_notify() is called before
> ofono_netreg_register() netreg->status_watches is NULL.
> ---
> src/network.c | 3 +++
> 1 file changed, 3 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register()
2017-09-11 0:25 ` [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register() Alexander Couzens
@ 2017-09-11 15:41 ` Denis Kenzior
0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2017-09-11 15:41 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Hi Alexander,
On 09/10/2017 07:25 PM, Alexander Couzens wrote:
> When registering callbacks before ofono_netreg_register(), callbacks
> will use the netreg api which might lead into undefined behaviour,
> because certain fields aren't yet initilized.
> ---
> drivers/qmimodem/network-registration.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-11 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-11 0:25 [PATCH 1/2] network.c: notify_status_watches: check for NULL Alexander Couzens
2017-09-11 0:25 ` [PATCH 2/2] qmimodem/network-registration: register callbacks after ofono_netreg_register() Alexander Couzens
2017-09-11 15:41 ` Denis Kenzior
2017-09-11 15:39 ` [PATCH 1/2] network.c: notify_status_watches: check for NULL Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox