summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen-Chao Chen <davidycchen@google.com>2023-03-09 14:12:40 +0800
committerYen-Chao Chen <davidycchen@google.com>2023-03-13 16:58:15 +0800
commit33ca5c1b899fb07fe241a8a6070437c0a28d0891 (patch)
tree07c8aefc3c686a36c041ab5b7321c370284fd0a9
parent846df03df69cbd9863758cb3d51bc1b0668ae53a (diff)
downloadfelix-33ca5c1b899fb07fe241a8a6070437c0a28d0891.tar.gz
fst2: Correct memory allocation length
Bug: 271960925 Test: build pass Change-Id: Ie8007ab9857bfa43a1217b5f830e99fd53f5d7a2 Signed-off-by: Yen-Chao Chen <davidycchen@google.com>
-rw-r--r--touch/fst2/fts_proc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/touch/fst2/fts_proc.c b/touch/fst2/fts_proc.c
index 9ceaf19..8ee0eac 100644
--- a/touch/fst2/fts_proc.c
+++ b/touch/fst2/fts_proc.c
@@ -150,7 +150,8 @@ cat /proc/fts/driver_test ==> Prevent the driver
from transitioning the ownership of the bus to SLPI.
Single parameter indicates force touch state */
-
+/* The string length when there is no data to print. */
+#define NO_DATA_STRING_LEN 14
static int limit; /* /< store the amount of data to print into the shell*/
static int chunk; /* /< store the chuk of data that should be printed in
@@ -184,8 +185,12 @@ static void *fts_seq_start(struct seq_file *s, loff_t *pos)
if (test_print_buff == NULL && *pos == 0) {
LOGI("%s: No data to print!\n", __func__);
- test_print_buff = (u8 *)kmalloc(13 * sizeof(u8), GFP_KERNEL);
- snprintf(test_print_buff, 14, "{ %08X }\n", ERROR_OP_NOT_ALLOW);
+ test_print_buff = (u8 *)kmalloc(NO_DATA_STRING_LEN * sizeof(u8), GFP_KERNEL);
+ if (test_print_buff == NULL) {
+ LOGE("%s: Error allocating memory\n", __func__);
+ return NULL;
+ }
+ snprintf(test_print_buff, NO_DATA_STRING_LEN, "{ %08X }\n", ERROR_OP_NOT_ALLOW);
limit = strlen(test_print_buff);
} else {
if (*pos != 0)