summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchasewu <chasewu@google.com>2022-03-15 21:45:40 +0800
committerChase Wu <chasewu@google.com>2022-03-15 15:00:13 +0000
commit7ebeddfe8c51aefbcfedf2373e8efb1e24e6bdd5 (patch)
treee9241ac23bb6a7b5ce28b62b6c55c3c168e064a3
parente4de0484907fe0553a472fb98090844d41f19270 (diff)
downloadamplifiers-7ebeddfe8c51aefbcfedf2373e8efb1e24e6bdd5.tar.gz
cs40l25: fix the PWLE size length problem
Branch: v5.10-cs40l25 Commits: 3020ec719047 misc: cs40l25: Change max size of PWLE string 0f44b3c59460 misc: cs40l25: Resolved memory leaks Bug: 200160363 Test: adb shell cmd vibrator_manager synced waveform -a -c \ 10 0 10 51 10 76 10 51 \ 10 0 10 51 10 76 10 51 10 0 10 51 10 76 10 51 \ 10 0 10 51 10 76 10 51 10 0 10 51 10 76 10 51 \ 10 0 10 51 10 76 10 51 10 0 10 51 10 76 10 51 \ 10 76 10 51 10 0 10 51 10 76 10 51 Signed-off-by: chasewu <chasewu@google.com> Change-Id: I700fd8eda40131d85ebc7d0e97481fb26deb3a1a
-rw-r--r--cs40l25/cs40l2x.c8
-rw-r--r--cs40l25/include/linux/mfd/cs40l2x.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/cs40l25/cs40l2x.c b/cs40l25/cs40l2x.c
index f5867be..1381118 100644
--- a/cs40l25/cs40l2x.c
+++ b/cs40l25/cs40l2x.c
@@ -1144,7 +1144,8 @@ static int cs40l2x_convert_and_save_comp_data(struct cs40l2x_private *cs40l2x,
if (comp_size > (cs40l2x->comp_bytes / CS40L2X_WT_NUM_VIRT_SLOTS)) {
dev_err(cs40l2x->dev, "Waveform size exceeds available space\n");
- return -ENOSPC;
+ ret = -ENOSPC;
+ goto err_free;
}
if (over_write)
@@ -1725,6 +1726,7 @@ static int cs40l2x_save_packed_pwle_data(struct cs40l2x_private *cs40l2x,
if (ret > (cs40l2x->comp_bytes / CS40L2X_WT_NUM_VIRT_SLOTS)) {
dev_err(cs40l2x->dev, "PWLE size exceeds available space\n");
+ kfree(zero_pad_data);
return -ENOSPC;
}
@@ -1926,7 +1928,7 @@ static ssize_t cs40l2x_pwle_store(struct device *dev,
bool a = false, v = false;
int ret;
- if (count > CS40L2X_PWLE_TOTAL_VALS - 1) {
+ if (count > CS40L2X_PWLE_BYTES_MAX - 1) {
dev_err(dev, "PWLE string too large\n");
return -E2BIG;
}
@@ -2157,7 +2159,7 @@ static ssize_t cs40l2x_pwle_store(struct device *dev,
pwle->nsections = num_segs;
- ret = strscpy_pad(cs40l2x->pwle_str, buf, CS40L2X_PWLE_TOTAL_VALS);
+ ret = strscpy_pad(cs40l2x->pwle_str, buf, CS40L2X_PWLE_BYTES_MAX);
if (ret == -E2BIG) {
goto err_exit;
}
diff --git a/cs40l25/include/linux/mfd/cs40l2x.h b/cs40l25/include/linux/mfd/cs40l2x.h
index 2c7d404..ee2b9e3 100644
--- a/cs40l25/include/linux/mfd/cs40l2x.h
+++ b/cs40l25/include/linux/mfd/cs40l2x.h
@@ -1436,7 +1436,7 @@ struct cs40l2x_private {
bool xm_append;
char wt_file[CS40L2X_WT_FILE_NAME_LEN_MAX];
char wt_date[CS40L2X_WT_FILE_DATE_LEN_MAX];
- char pwle_str[CS40L2X_PWLE_TOTAL_VALS];
+ char pwle_str[CS40L2X_PWLE_BYTES_MAX];
bool exc_available;
struct cs40l2x_dblk_desc pre_dblks[CS40L2X_MAX_A2H_LEVELS];
struct cs40l2x_dblk_desc a2h_dblks[CS40L2X_MAX_A2H_LEVELS];