Message ID | CAGBcZGf5+OkF1QQOJocVHuSKFgC1+rjiNuSBK3Oo3nBfr5RXdw@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Tue, 04 Nov, at 03:56:22PM, Sam Protsenko wrote: > Matt, > > I've tested your patch with zero image size (no image passed, only headers) > and it crashes because there is no check for image size there. > This case (zero image size) seems to be legit according to specification > and also can be useful in real life. So I developed a little fix for your patch: [...] > I'm planning to use your API for our UpdateCapsule test module so > it would be really helpful if you can include this fix to your patch. Sure, I'll include that snippet and post fixed up code next week. Thanks Sam.
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index ca29bad..597b363 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -169,13 +169,17 @@ static int efi_update_capsule(efi_capsule_header_t *capsule, struct page **pages, size_t size, int reset) { efi_capsule_block_desc_t *block = NULL; - struct page **block_pgs; + struct page **block_pgs = NULL; efi_status_t status; - unsigned int nr_data_pgs, nr_block_pgs; + unsigned int nr_data_pgs = 0, nr_block_pgs = 0; + unsigned long sg_list = 0; int i, j, err = -ENOMEM; lockdep_assert_held(&capsule_mutex); + if (size == 0) + goto update_caps; + nr_data_pgs = DIV_ROUND_UP(size, PAGE_SIZE); nr_block_pgs = num_block_pages(nr_data_pgs);