Sam Protsenko 04c63f134c cmd: gpt: Fix freeing gpt_pte in gpt_verify()
In case when either gpt_verify_headers() or gpt_verify_partitions()
fails, the memory allocated for gpt_pte will be freed in those functions
internally, but gpt_pte will still contain non-NULL dangling pointer.
The attempt to free it in those cases in gpt_verify() leads to "use
after free" error, which leads to a "Synchronous abort" exception.

This issue was found by running the next command on the device with
incorrect partition table:

    => gpt verify mmc 0 $partitions

which results to:

    No partition list provided - only basic check
    "Synchronous Abort" handler, esr 0x96000021, far 0xba247bff
    ....

Fix the issue by only freeing gpt_pte if none of those functions failed.

Fixes: bbb9ffac6066 ("gpt: command: Extend gpt command to support GPT table verification")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2024-06-26 13:17:51 -06:00
..
2017-02-08 15:56:28 -05:00
2024-02-15 10:38:34 +01:00
2024-06-14 12:59:07 -06:00
2022-03-15 16:19:29 -04:00
2024-06-24 13:34:52 -06:00
2024-03-07 09:23:10 -05:00
2024-05-22 08:55:29 -06:00
2022-09-02 13:40:42 -04:00
2024-06-24 13:34:52 -06:00
2020-08-07 22:31:32 -04:00
2024-06-04 08:09:09 -06:00
2024-06-24 13:34:52 -06:00