Re: [PATCH] libexfat: fix return value of exfat_check_written_data()

Namjae Jeon <[email protected]>
Newsgroups dev.linux.lists.exfat
Message-ID <CAKYAXd9oqN28RASa1pewk-i5FFdjX68Q1zuwgKkdUWgz_ryyew@mail.gmail.com>
On Sat, Aug 8, 2026 at 3:58 PM David Timber <[email protected]> wrote:
>
> In exfat_check_written_data(), the return value of posix_memalign() is
> only used to check if the memory allocation failed and the errno is
> returned from the function. However, according to posix_memalign(3),
> errno shouldn't be set by posix_memalign() at all.
>
> Overflows and invalid allocation lengths are already checked with
> assert() beforehand. Therefore, EINVAL should never be returned from
> posix_memalign(). So, always return -ENOMEM if allocation fails.
>
> Note that currently, this patch doesn't really fix any issue because
> with all the current Linux libc implementations(glibc and musl), errno
> is set for ENOMEM cases in posix_memalign() anyway. This patch is only
> to fix potential undefined behaviour on other POSIX platforms in the
> future.
>
> Fixes: 78e398e37ba5 ("exfatprogs: Fix and improve verify written zeros (memory optimisations)")
> Signed-off-by: David Timber <[email protected]>
Applied it to #exfat-next.
Thanks!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.