aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-08-23 01:33:19 +0400
committerAlexander Tarasikov <alexander.tarasikov@gmail.com>2012-08-23 01:33:19 +0400
commitb11be643a3d129324aea655587a5b9d44932bd2b (patch)
tree72e08b3c8153779682b9198bc7ce99661a2779d1 /samsung-ipc
parentbbea04f2a29cc1dcb5ec13079942f61cd673ba61 (diff)
downloadexternal_libsamsung-ipc-b11be643a3d129324aea655587a5b9d44932bd2b.zip
external_libsamsung-ipc-b11be643a3d129324aea655587a5b9d44932bd2b.tar.gz
external_libsamsung-ipc-b11be643a3d129324aea655587a5b9d44932bd2b.tar.bz2
[xmm6260] add ipc error checks
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/device/xmm6260/xmm6260_ipc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
index c088e6e..7544fd3 100644
--- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c
+++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c
@@ -100,12 +100,15 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
int num_read = 0;
int left = 0;
+ if (!client || !response)
+ return -1;
+
wake_lock(FMT_LOCK_NAME);
num_read = client->handlers->read(buf, IPC_MAX_XFER,
client->handlers->read_data);
- if (num_read < 0) {
+ if (num_read <= 0) {
ipc_client_log(client, "read failed to read ipc length: %d", num_read);
response->data = 0;
response->length = 0;
@@ -128,9 +131,11 @@ int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_in
response->index = ipc.index;
response->type = ipc.type;
response->length = ipc.length - sizeof(ipc);
-
- response->data = (unsigned char*)malloc(response->length);
- memcpy(response->data, buf + sizeof(ipc), response->length);
+
+ if (response->length > 0) {
+ response->data = (unsigned char*)malloc(response->length);
+ memcpy(response->data, buf + sizeof(ipc), response->length);
+ }
ipc_client_log_recv(client, response, __func__);