aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornailyk-fr <nailyk_git@nailyk.fr>2016-10-08 20:18:30 +0200
committernailyk-fr <nailyk_git@nailyk.fr>2017-02-21 20:15:18 +0100
commit680b9b4c3a7c23a86331a44b597e93fa44f1a7ed (patch)
tree3eafef05a483efb98b310aeada8ee512a168571e
parentf324364ca45a1962a51c223f1a017168b2ffb1b8 (diff)
shinano-common: tfa: Fix logic mistake in ioctl for eq function
A fixed-length array of unsigned char can never be NULL! Fix the logic by initializing the array correctly and assigning to the param struct if we copied anything with memcpy into it instead of doing an useless null check. https://github.com/sonyxperiadev/device-sony-shinano/commit/12d9e45b473fc4354d8acbef2bd8ba05111ed9a1 Change-Id: I31b648ce4c6a2b2752020172d0aa2e4b75b7852a
-rw-r--r--tfa9890/tfa9890.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tfa9890/tfa9890.c b/tfa9890/tfa9890.c
index b3e0d0c..0a73a3a 100644
--- a/tfa9890/tfa9890.c
+++ b/tfa9890/tfa9890.c
@@ -75,7 +75,7 @@ int tfa9890_prepare_for_ioctl(const char *file_name, unsigned int type) {
int tfa9890_prepare_for_ioctl_eq(const char *file_name, unsigned int type) {
unsigned int size;
- unsigned char buf[PARAM_SIZE_MAX];
+ unsigned char buf[PARAM_SIZE_MAX] = {0};
ALOGV("Preparing %s", file_name);
@@ -88,12 +88,12 @@ int tfa9890_prepare_for_ioctl_eq(const char *file_name, unsigned int type) {
memcpy(buf, eq_data[type], size);
/* Set the data for the ioctl arg */
- if (size)
+ if (size) {
tfa9890_param_data.size = size;
+ tfa9890_param_data.data = buf;
+ }
if (type)
tfa9890_param_data.type = type;
- if (buf != NULL)
- tfa9890_param_data.data = buf;
return 0;
}