speakup: i18n: Switch to kmemdup_nul() in spk_msg_set()
PATCH v2 1/1 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 <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
---
V2:
change the tile and commit log.
--- drivers/accessibility/speakup/i18n.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/accessibility/speakup/i18n.c +1 -3
@@ -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)) {
Signature · 1 line
2.25.1