[syslinux:multifs] efi/multifs: fix misuse of static private information
syslinux-bot for Paulo Alcantara
pcacjr at zytor.com
Mon Feb 1 03:18:09 PST 2016
Commit-ID: 83a71e559573ebd8e0a3189ddb279042497816fd
Gitweb: http://www.syslinux.org/commit/83a71e559573ebd8e0a3189ddb279042497816fd
Author: Paulo Alcantara <pcacjr at zytor.com>
AuthorDate: Wed, 22 Jul 2015 03:20:20 -0300
Committer: Paulo Alcantara <pcacjr at zytor.com>
CommitDate: Sun, 31 Jan 2016 18:35:19 -0200
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 at gmail.com>
Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>
---
efi/multifs.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/efi/multifs.c b/efi/multifs.c
index 418d0c2..63bf73e 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);
More information about the Syslinux-commits
mailing list