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-23 01:42:36 +0000
commita037c2237428bacf0fb3380c2172fe690dd92946 (patch)
tree21933417127b140ddd09239cfed06873d5d0ad9e
parent5feba8df697678ce43127315ba5e5098565567dd (diff)
downloadfelix-a037c2237428bacf0fb3380c2172fe690dd92946.tar.gz
fst2: Correct memory allocation length
Bug: 271960925 Test: build pass Change-Id: Ie8007ab9857bfa43a1217b5f830e99fd53f5d7a2 Signed-off-by: Yen-Chao Chen <davidycchen@google.com> (cherry picked from commit 33ca5c1b899fb07fe241a8a6070437c0a28d0891)
-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)