aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2014-06-29 21:41:41 +0200
committerH. Peter Anvin <hpa@zytor.com>2014-08-26 18:07:18 -0700
commit68e8acb564a1b0e591d73edb912aa703c54ba2df (patch)
treef672fed944658279b83c6dab2e6318273fc61d24
parent69e1b85fdee3db74cadf2e61e9ab34a9f70ab981 (diff)
downloadsyslinux-68e8acb564a1b0e591d73edb912aa703c54ba2df.tar.gz
syslinux-68e8acb564a1b0e591d73edb912aa703c54ba2df.tar.xz
syslinux-68e8acb564a1b0e591d73edb912aa703c54ba2df.zip
chain: add missing pi_del() in find*() functions
As partiter doesn't deallocate itself after finish (anymore), it should be deleted after each loop iteration. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/chain/chain.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index c08ec6e0..f86cd7d3 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -64,27 +64,23 @@ static int is_phys(uint8_t sdifs)
static int find_by_sig(uint32_t mbr_sig,
struct part_iter **_boot_part)
{
- struct part_iter *boot_part = NULL;
+ struct part_iter *iter = NULL;
struct disk_info diskinfo;
int drive;
for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.piflags)))
- continue;
- /* Check for a MBR disk */
- if (boot_part->type != typedos) {
- pi_del(&boot_part);
+ if (!(iter = pi_begin(&diskinfo, opt.piflags)))
continue;
- }
- if (boot_part->dos.disk_sig == mbr_sig) {
+ /* Check for a matching MBR disk */
+ if (iter->type == typedos && iter->dos.disk_sig == mbr_sig)
goto ok;
- }
+ pi_del(&iter);
}
drive = -1;
ok:
- *_boot_part = boot_part;
+ *_boot_part = iter;
return drive;
}
@@ -95,29 +91,26 @@ ok:
static int find_by_guid(const struct guid *gpt_guid,
struct part_iter **_boot_part)
{
- struct part_iter *boot_part = NULL;
+ struct part_iter *iter = NULL;
struct disk_info diskinfo;
int drive;
for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.piflags)))
- continue;
- /* Check for a GPT disk */
- if (boot_part->type != typegpt) {
- pi_del(&boot_part);
+ if (!(iter = pi_begin(&diskinfo, opt.piflags)))
continue;
- }
/* Check for a matching GPT disk/partition guid */
- do {
- if (!memcmp(&boot_part->gpt.part_guid, gpt_guid, sizeof *gpt_guid))
- goto ok;
- } while (!pi_next(boot_part));
+ if (iter->type == typegpt)
+ do {
+ if (!memcmp(&iter->gpt.part_guid, gpt_guid, sizeof *gpt_guid))
+ goto ok;
+ } while (!pi_next(iter));
+ pi_del(&iter);
}
drive = -1;
ok:
- *_boot_part = boot_part;
+ *_boot_part = iter;
return drive;
}
@@ -127,29 +120,26 @@ ok:
*/
static int find_by_label(const char *label, struct part_iter **_boot_part)
{
- struct part_iter *boot_part = NULL;
+ struct part_iter *iter = NULL;
struct disk_info diskinfo;
int drive;
for (drive = 0x80; drive < 0x80 + fixed_cnt; drive++) {
if (disk_get_params(drive, &diskinfo))
continue; /* Drive doesn't exist */
- if (!(boot_part = pi_begin(&diskinfo, opt.piflags)))
- continue;
- /* Check for a GPT disk */
- if (!(boot_part->type == typegpt)) {
- pi_del(&boot_part);
+ if (!(iter = pi_begin(&diskinfo, opt.piflags)))
continue;
- }
- /* Check for a matching partition */
- while (!pi_next(boot_part)) {
- if (!strcmp(label, boot_part->gpt.part_label))
- goto ok;
- }
+ /* Check for a matching GPT partition label */
+ if (iter->type == typegpt)
+ while (!pi_next(iter)) {
+ if (!strcmp(label, iter->gpt.part_label))
+ goto ok;
+ }
+ pi_del(&iter);
}
drive = -1;
ok:
- *_boot_part = boot_part;
+ *_boot_part = iter;
return drive;
}