From e45af077d807ab3a0878ab9bd69e36c3afdb85b4 Mon Sep 17 00:00:00 2001 From: Xiaoyu Ye Date: Tue, 31 Jul 2018 12:03:27 -0700 Subject: [PATCH] asoc: wcd9360-dsp-cntl: initialize local char array val Due to the local char array that stores the codec dsp control command is not initialized, an invalid command could cause the stack content to be printed out in kernel dmesg. Initialize the array with memset. Change-Id: I07211c4cc06b2c2df21b674e6812c4d5efc45dc4 Signed-off-by: Xiaoyu Ye --- asoc/codecs/wcd9360/wcd9360-dsp-cntl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c b/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c index 863024a98b64..37536f86c54c 100644 --- a/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c +++ b/asoc/codecs/wcd9360/wcd9360-dsp-cntl.c @@ -894,10 +894,12 @@ static ssize_t wcd_miscdev_write(struct file *filep, const char __user *ubuf, { struct wcd_dsp_cntl *cntl = container_of(filep->private_data, struct wcd_dsp_cntl, miscdev); - char val[WCD_MISCDEV_CMD_MAX_LEN]; + char val[WCD_MISCDEV_CMD_MAX_LEN + 1]; bool vote; int ret = 0; + memset(val, 0, WCD_MISCDEV_CMD_MAX_LEN + 1); + if (count == 0 || count > WCD_MISCDEV_CMD_MAX_LEN) { pr_err("%s: Invalid count = %zd\n", __func__, count); ret = -EINVAL;