From 680b9b4c3a7c23a86331a44b597e93fa44f1a7ed Mon Sep 17 00:00:00 2001 From: nailyk-fr Date: Sat, 8 Oct 2016 20:18:30 +0200 Subject: 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 --- tfa9890/tfa9890.c | 8 ++++---- 1 file 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; } -- cgit v1.2.3