Skip to content
Snippets Groups Projects
Commit 2c3c5b69 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Yang Yingliang
Browse files

modpost: add read_text_file() and get_line() helpers


mainline inclusion
from mainline-5.8
commit ac5100f5
category: bugfix
bugzilla: 46847
CVE: NA

-----------------------------------------------

modpost uses grab_file() to open a file, but it is not suitable for
a text file because the mmap'ed file is not terminated by null byte.
Actually, I see some issues for the use of grab_file().

The new helper, read_text_file() loads the whole file content into a
malloc'ed buffer, and appends a null byte. Then, get_line() reads
each line.

To handle text files, I intend to replace as follows:

  grab_file()    -> read_text_file()
  get_new_line() -> get_line()

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Signed-off-by: default avatarWang Wensheng <wangwensheng4@huawei.com>
Reviewed-by: default avatarJian Cheng <cj.chengjian@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent d4fcfb2e
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment