aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@zytor.com>2015-07-22 03:20:20 -0300
committerPaulo Alcantara <pcacjr@zytor.com>2016-01-31 18:35:19 -0200
commit83a71e559573ebd8e0a3189ddb279042497816fd (patch)
treec775eedfc02b8ab51dc0ca0ea636eba577792841
parent82fc42338f58fb59b83e42ab117d40d081cb0115 (diff)
downloadsyslinux-83a71e559573ebd8e0a3189ddb279042497816fd.tar.gz
syslinux-83a71e559573ebd8e0a3189ddb279042497816fd.tar.xz
syslinux-83a71e559573ebd8e0a3189ddb279042497816fd.zip
efi/multifs: fix misuse of static private information
The get_dev_info_priv() function cannot return a reference of a static variable since there might be multiple device handles and each one per logical partition. A typical example of this failure is when a configuration file contains multifs-path-syntax like, so multifs will initialised to the first partition found (including its device handle) and the other ones will be using the same partition to do I/O. Cc: Gene Cumm <gene.cumm@gmail.com> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
-rw-r--r--efi/multifs.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/efi/multifs.c b/efi/multifs.c
index 418d0c2c..63bf73e4 100644
--- a/efi/multifs.c
+++ b/efi/multifs.c
@@ -97,11 +97,15 @@ static inline EFI_HANDLE find_device_handle(unsigned int diskno,
return get_logical_part(partno);
}
-static inline void *get_dev_info_priv(EFI_HANDLE lpart)
+static inline void *get_dev_info_priv(EFI_HANDLE handle)
{
- static struct efi_disk_private priv;
- priv.dev_handle = lpart;
- return (void *)&priv;
+ struct efi_disk_private *priv;
+
+ priv = malloc(sizeof(*priv));
+ if (!priv)
+ return NULL;
+ priv->dev_handle = handle;
+ return priv;
}
__export struct fs_info *efi_multifs_get_fs_info(const char **path)
@@ -136,11 +140,11 @@ __export struct fs_info *efi_multifs_get_fs_info(const char **path)
ret = multifs_setup_fs_info(fsp, diskno, partno, priv);
if (ret) {
dprintf("%s: failed to set up fs info\n", __func__);
- goto free_dev_info;
+ goto free_priv;
}
return fsp;
-free_dev_info:
+free_priv:
free(priv);
free_fsp:
free(fsp);