Commit 3d47a34b authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Michael S. Tsirkin

fw_cfg: fix sparse warnings around FW_CFG_FILE_DIR read

Use struct fw_cfg_files to read the directory size, fixing the sparse
warnings:

drivers/firmware/qemu_fw_cfg.c:485:17: warning: cast to restricted __be32
Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent f295c8db
......@@ -496,19 +496,20 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)
static int fw_cfg_register_dir_entries(void)
{
int ret = 0;
__be32 files_count;
u32 count, i;
struct fw_cfg_file *dir;
size_t dir_size;
fw_cfg_read_blob(FW_CFG_FILE_DIR, &count, 0, sizeof(count));
count = be32_to_cpu(count);
fw_cfg_read_blob(FW_CFG_FILE_DIR, &files_count, 0, sizeof(files_count));
count = be32_to_cpu(files_count);
dir_size = count * sizeof(struct fw_cfg_file);
dir = kmalloc(dir_size, GFP_KERNEL);
if (!dir)
return -ENOMEM;
fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(count), dir_size);
fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(files_count), dir_size);
for (i = 0; i < count; i++) {
ret = fw_cfg_register_file(&dir[i]);
......
Markdown is supported
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