提交 6af6b163 编写于 作者: D Dmitry Kasatkin 提交者: Greg Kroah-Hartman

firmware: read firmware size using i_size_read()

There is no need to read attr because inode structure contains size
of the file. Use i_size_read() instead.
Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
Acked-by: NMing Lei <ming.lei@canonical.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 5a1379e8
...@@ -284,26 +284,15 @@ static const char * const fw_path[] = { ...@@ -284,26 +284,15 @@ static const char * const fw_path[] = {
module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
/* Don't inline this: 'struct kstat' is biggish */
static noinline_for_stack int fw_file_size(struct file *file)
{
struct kstat st;
if (vfs_getattr(&file->f_path, &st))
return -1;
if (!S_ISREG(st.mode))
return -1;
if (st.size != (int)st.size)
return -1;
return st.size;
}
static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
{ {
int size; int size;
char *buf; char *buf;
int rc; int rc;
size = fw_file_size(file); if (!S_ISREG(file_inode(file)->i_mode))
return -EINVAL;
size = i_size_read(file_inode(file));
if (size <= 0) if (size <= 0)
return -EINVAL; return -EINVAL;
buf = vmalloc(size); buf = vmalloc(size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册