From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Matthew Garrett <mjg@redhat.com>
Subject: Re: [PATCH V3 2/3] Add support for avoiding firmware in relocations
Date: Wed, 08 Feb 2012 20:41:11 +0100 [thread overview]
Message-ID: <4F32CFD7.1050202@gmail.com> (raw)
In-Reply-To: <1328720102-4914-2-git-send-email-mjg@redhat.com>
On 08.02.2012 17:55, Matthew Garrett wrote:
> EFI and OF both support firmware regions which may be in use during loading.
>
> +unsigned
> +grub_relocator_firmware_overlaps (grub_phys_addr_t target, grub_size_t size)
> +{
> + grub_efi_uintn_t mmapsize = 0, desc_size = 0;
> + grub_efi_uint32_t descriptor_version = 0;
> + grub_efi_memory_descriptor_t *descs = NULL;
> + grub_efi_uintn_t key;
> + int overlap = 0;
> + grub_efi_memory_descriptor_t *desc;
> +
> + grub_efi_get_memory_map (&mmapsize, NULL,&key,&desc_size,
> + &descriptor_version);
You need to check return value.
You don't use key. You can just make it NULL (grub_efi_get_memory_map
handles it).
> + descs = grub_malloc (mmapsize);
> + if (!descs)
> + return 0;
> +
You seem to lack error handling as whole. I'd suggest make this function
return grub_err_t and generate a grub_error itself if overlap is detected.
You current code would happily allocate anywhere if grub_malloc fails.
> + grub_efi_get_memory_map (&mmapsize, descs,&key,&desc_size,
> + &descriptor_version);
> +
> +
> adjust_limits (rel,&min_addr,&max_addr, target, target);
>
> + if (avoid_firmware)
> + {
> +#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
> + if (grub_relocator_firmware_overlaps(target, size))
> +
> + return grub_error(GRUB_ERR_BAD_ARGUMENT, "target overlaps with firmware");
> +#endif
> + }
> +
Ditto. Also here you have indentation problem
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
next prev parent reply other threads:[~2012-02-08 19:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 16:55 [PATCH V3 1/3] Update the Linux boot protocol Matthew Garrett
2012-02-08 16:55 ` [PATCH V3 2/3] Add support for avoiding firmware in relocations Matthew Garrett
2012-02-08 19:41 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2012-02-08 22:22 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 22:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 16:55 ` [PATCH V3 3/3] Update Linux loader to follow the kernel's preferences Matthew Garrett
2012-02-08 19:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-08 19:35 ` [PATCH V3 1/3] Update the Linux boot protocol Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-26 21:01 ` Keshav P R
2012-02-26 21:12 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-26 21:18 ` Keshav P R
2012-02-26 21:22 ` Keshav P R
2012-02-26 21:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-02-26 21:34 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F32CFD7.1050202@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
--cc=mjg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.