diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2021-04-06 11:44:34 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-10 10:58:50 +0200 |
commit | 0d5cf954656387a595a8d5bb7e376f31829aae4d (patch) | |
tree | df82e000766a09634fa1b4ddbec5753be37894af /drivers/accessibility | |
parent | 6c00365d531163a44ce57d862883db9424bd19ab (diff) |
speakup: i18n: Switch to kmemdup_nul() in spk_msg_set()
Use kmemdup_nul() helper instead of open-coding to
simplify the code in spk_msg_set().
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210406034434.442251-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/accessibility')
-rw-r--r-- | drivers/accessibility/speakup/i18n.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/accessibility/speakup/i18n.c b/drivers/accessibility/speakup/i18n.c index ee240d36f947..46bd50f3c3a4 100644 --- a/drivers/accessibility/speakup/i18n.c +++ b/drivers/accessibility/speakup/i18n.c @@ -548,12 +548,10 @@ ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length) if ((index < MSG_FIRST_INDEX) || (index >= MSG_LAST_INDEX)) return -EINVAL; - newstr = kmalloc(length + 1, GFP_KERNEL); + newstr = kmemdup_nul(text, length, GFP_KERNEL); if (!newstr) return -ENOMEM; - memcpy(newstr, text, length); - newstr[length] = '\0'; if (index >= MSG_FORMATTED_START && index <= MSG_FORMATTED_END && !fmt_validate(speakup_default_msgs[index], newstr)) { |