Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08da2012 authored by Ben Hutchings's avatar Ben Hutchings Committed by Greg Kroah-Hartman
Browse files

firmware_class: Fix the file size check



We expect to read firmware blobs with a single call to kernel_read(),
which returns int.  Therefore the size must be within the range of
int, not long.

Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 174be70b
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -280,21 +280,21 @@ 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 */
/* Don't inline this: 'struct kstat' is biggish */
static noinline_for_stack long fw_file_size(struct file *file)
static noinline_for_stack int fw_file_size(struct file *file)
{
{
	struct kstat st;
	struct kstat st;
	if (vfs_getattr(&file->f_path, &st))
	if (vfs_getattr(&file->f_path, &st))
		return -1;
		return -1;
	if (!S_ISREG(st.mode))
	if (!S_ISREG(st.mode))
		return -1;
		return -1;
	if (st.size != (long)st.size)
	if (st.size != (int)st.size)
		return -1;
		return -1;
	return st.size;
	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)
{
{
	long size;
	int size;
	char *buf;
	char *buf;
	int rc;
	int rc;