diff options
author | Anubhav Jain <anubhavj@nvidia.com> | 2016-08-02 10:14:55 +0530 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2016-08-19 11:23:54 -0700 |
commit | 0e1e56d8cbedfd627f5c98d782dd6802018acd91 (patch) | |
tree | 5110bfc2112002006c042ef1aaab6359d6fdf079 | |
parent | 1ac2e09a01fa85421ccead92c4bdd30ad272377f (diff) | |
download | tegra-0e1e56d8cbedfd627f5c98d782dd6802018acd91.tar.gz |
mmc: card: test: Fix out of boundary array access
Allocate buffer with 1 extra byte for NULL terminator.
Bug: 28760138
NvBug 1791602
Change-Id: I498b9a8a4f341a9a439650eaca14d6758fbf1e06
Signed-off-by: Xia Yang <xiay@nvidia.com>
(cherry picked from commit 7d2e9a2f74be34ef72f5985513073bd33580689b)
-rw-r--r-- | drivers/mmc/card/mmc_test.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index 3d5075a70e9a..e23cc5f97138 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c @@ -3021,7 +3021,7 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf, char *data_buf = NULL; long testcase; - data_buf = kzalloc(count, GFP_KERNEL); + data_buf = kzalloc(count + 1, GFP_KERNEL); if (data_buf == NULL) return -ENOMEM; @@ -3029,7 +3029,6 @@ static ssize_t mtf_test_write(struct file *file, const char __user *buf, kfree(data_buf); return -EFAULT; } - data_buf[strlen(data_buf) - 1] = '\0'; if (mmc_test_extract_parameters(data_buf)) { mmc_test_usage(sf); return -EFAULT; |