summaryrefslogtreecommitdiffstats
path: root/btif/src/btif_hh.c
diff options
context:
space:
mode:
authorZhihai Xu <zhihaixu@google.com>2014-04-22 00:35:42 +0530
committerZhihai Xu <zhihaixu@google.com>2014-04-21 19:17:54 +0000
commit45c71b0647cba0f199a8dfd1321c1b59a916cfe5 (patch)
tree3c36f21306063da34bcdf14a1e2b28b00abbf863 /btif/src/btif_hh.c
parentbf51271f145204a0489597ccd9c851daa7ee0ad7 (diff)
downloadandroid_system_bt-45c71b0647cba0f199a8dfd1321c1b59a916cfe5.tar.gz
android_system_bt-45c71b0647cba0f199a8dfd1321c1b59a916cfe5.tar.bz2
android_system_bt-45c71b0647cba0f199a8dfd1321c1b59a916cfe5.zip
HID: Use dynamic memory while sending report
This patch uses dynamic memory allocation while sending HID output data to remote device depending on size of data to be sent. Without this patch fixed size static buffer of 200 bytes was being used for sending data to remote device, which was resulting in crash in case data size to be sent to remote device was greater than 200 bytes. CL from qcom(Hemant Gupta) Change-Id: Icc8cd4a4ecfd4bc30cbf848a7c865fcf9308ddf8
Diffstat (limited to 'btif/src/btif_hh.c')
-rw-r--r--btif/src/btif_hh.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index 7b3495583..9c765b4af 100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
@@ -1612,11 +1612,18 @@ static bt_status_t set_report (bt_bdaddr_t *bd_addr, bthh_report_type_t reportTy
}
else {
int hex_bytes_filled;
- UINT8 hexbuf[200];
+ UINT8 *hexbuf;
UINT16 len = (strlen(report) + 1) / 2;
+ hexbuf = GKI_getbuf(len);
+ if (hexbuf == NULL) {
+ BTIF_TRACE_ERROR2("%s: Error, failed to allocate RPT buffer, len = %d",
+ __FUNCTION__, len);
+ return BT_STATUS_FAIL;
+ }
+
/* Build a SetReport data buffer */
- memset(hexbuf, 0, 200);
+ memset(hexbuf, 0, len);
//TODO
hex_bytes_filled = ascii_2_hex(report, len, hexbuf);
ALOGI("Hex bytes filled, hex value: %d", hex_bytes_filled);
@@ -1625,11 +1632,15 @@ static bt_status_t set_report (bt_bdaddr_t *bd_addr, bthh_report_type_t reportTy
if (p_buf == NULL) {
BTIF_TRACE_ERROR2("%s: Error, failed to allocate RPT buffer, len = %d",
__FUNCTION__, hex_bytes_filled);
+ GKI_freebuf(hexbuf);
return BT_STATUS_FAIL;
}
BTA_HhSetReport(p_dev->dev_handle, reportType, p_buf);
+ GKI_freebuf(hexbuf);
+ return BT_STATUS_SUCCESS;
}
- return BT_STATUS_SUCCESS;
+ GKI_freebuf(hexbuf);
+ return BT_STATUS_FAIL;
}
}