summaryrefslogtreecommitdiff
path: root/drivers/qmimodem/qmi.c
diff options
context:
space:
mode:
authorJonas Bonn <jonas@southpole.se>2018-04-03 16:50:52 +0200
committerDenis Kenzior <denkenz@gmail.com>2018-04-04 09:55:21 -0500
commita357565377a3443928cfd8d32d1dedd98bf3c708 (patch)
treedddee4c0d03c063fca4dbf09e39e9ff27da6c3c9 /drivers/qmimodem/qmi.c
parent093bdda7bece88e99e631a7d7ad4a5ea9910d746 (diff)
downloadofono-a357565377a3443928cfd8d32d1dedd98bf3c708.tar.gz
qmi: request_alloc has no meaningful failure path
The only way request_alloc can fail is if one of the memory allocation routines fail to allocate memory. However, Linux memory allocation doesn't really fail in this manner; memory can be overcommited and the out-of-memory reaper will take care of re-establishing the balance when excess memory is actually accessed. Given this, request_alloc will never return anything other than success and the failure paths will never be exercised.
Diffstat (limited to 'drivers/qmimodem/qmi.c')
-rw-r--r--drivers/qmimodem/qmi.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c
index ff7d8592..b1183166 100644
--- a/drivers/qmimodem/qmi.c
+++ b/drivers/qmimodem/qmi.c
@@ -170,9 +170,7 @@ static struct qmi_request *__request_alloc(uint8_t service,
struct qmi_message_hdr *msg;
uint16_t headroom;
- req = g_try_new0(struct qmi_request, 1);
- if (!req)
- return NULL;
+ req = g_new0(struct qmi_request, 1);
if (service == QMI_SERVICE_CONTROL)
headroom = QMI_CONTROL_HDR_SIZE;
@@ -181,11 +179,7 @@ static struct qmi_request *__request_alloc(uint8_t service,
req->len = QMI_MUX_HDR_SIZE + headroom + QMI_MESSAGE_HDR_SIZE + length;
- req->buf = g_try_malloc(req->len);
- if (!req->buf) {
- g_free(req);
- return NULL;
- }
+ req->buf = g_malloc(req->len);
req->client = client;
@@ -1282,10 +1276,6 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
QMI_CTL_GET_VERSION_INFO,
NULL, 0, discover_callback, data, (void **) &hdr);
- if (!req) {
- g_free(data);
- return false;
- }
data->tid = hdr->transaction;
@@ -1309,10 +1299,6 @@ static void release_client(struct qmi_device *device,
QMI_CTL_RELEASE_CLIENT_ID,
release_req, sizeof(release_req),
func, user_data, (void **) &hdr);
- if (!req) {
- func(0x0000, 0x0000, NULL, user_data);
- return;
- }
__request_submit(device, req);
}
@@ -2028,15 +2014,6 @@ static void service_create_discover(uint8_t count,
QMI_CTL_GET_CLIENT_ID,
client_req, sizeof(client_req),
service_create_callback, data, (void **) &hdr);
- if (!req) {
- if (data->timeout > 0)
- g_source_remove(data->timeout);
-
- data->timeout = g_timeout_add_seconds(0,
- service_create_reply, data);
- __qmi_device_discovery_started(device, &data->super);
- return;
- }
__request_submit(device, req);
}
@@ -2320,11 +2297,6 @@ uint16_t qmi_service_send(struct qmi_service *service,
param ? param->length : 0,
service_send_callback, data, (void **) &hdr);
- if (!req) {
- g_free(data);
- return 0;
- }
-
qmi_param_free(param);
__request_submit(device, req);