[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] acpi: handle return value of mmap consistently in acpi.c
From: |
Samuel Thibault |
Subject: |
Re: [PATCH] acpi: handle return value of mmap consistently in acpi.c |
Date: |
Sun, 21 Nov 2021 20:24:10 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Hello,
Applied, thanks!
Samuel
Andrea Monaco, le ven. 19 nov. 2021 00:05:38 +0100, a ecrit:
>
> Hello.
>
>
> In the first chunk, munmap is not needed, because mmap_phys_acpi_header
> only returns non-zero when mmap fails.
> In the second, a possible error condition was previously ignored.
> In the last chunk, I moved a common identical branch lower.
>
>
> Bye,
>
> Andrea Monaco
>
>
>
> diff --git a/acpi/acpi.c b/acpi/acpi.c
> index acbf79c7..7ab139f6 100644
> --- a/acpi/acpi.c
> +++ b/acpi/acpi.c
> @@ -114,7 +114,6 @@ acpi_get_num_tables(size_t *num_tables)
>
> err = mmap_phys_acpi_header(sdt_base, &root_sdt, &virt_addr, fd_mem);
> if (err) {
> - munmap(virt_addr, ESCD_SIZE);
> return err;
> }
>
> @@ -139,6 +138,11 @@ acpi_get_num_tables(size_t *num_tables)
> err = mmap_phys_acpi_header(acpi_ptr32, &next, &virt_addr2, fd_mem);
> }
>
> + if (err) {
> + munmap(virt_addr, ESCD_SIZE);
> + return err;
> + }
> +
> if (next->signature[0] == '\0' || next->length == 0) {
> munmap(virt_addr2, ESCD_SIZE);
> continue;
> @@ -223,7 +227,6 @@ acpi_get_tables(struct acpi_table **tables)
>
> err = mmap_phys_acpi_header(sdt_base, &root_sdt, &virt_addr, fd_mem);
> if (err) {
> - munmap(virt_addr, ESCD_SIZE);
> return err;
> }
>
> @@ -243,16 +246,13 @@ acpi_get_tables(struct acpi_table **tables)
> uintptr_t acpi_ptr64 = (uintptr_t)*((uint64_t *)(acpi_ptr + i*sz_ptr));
> if (is_64bit) {
> err = mmap_phys_acpi_header(acpi_ptr64, &next, &virt_addr2, fd_mem);
> - if (err) {
> - munmap(virt_addr, ESCD_SIZE);
> - return err;
> - }
> } else {
> err = mmap_phys_acpi_header(acpi_ptr32, &next, &virt_addr2, fd_mem);
> - if (err) {
> - munmap(virt_addr, ESCD_SIZE);
> - return err;
> - }
> + }
> +
> + if (err) {
> + munmap(virt_addr, ESCD_SIZE);
> + return err;
> }
>
> if (next->signature[0] == '\0' || next->length == 0) {
>
>
--
Samuel
"And the next time you consider complaining that running Lucid Emacs
19.05 via NFS from a remote Linux machine in Paraguay doesn't seem to
get the background colors right, you'll know who to thank."
(By Matt Welsh)