]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commit
src/fill2: fix segfault during fopen error cleanup
authorAnthony Iliopoulos <ailiop@suse.com>
Thu, 12 Jun 2025 19:05:13 +0000 (21:05 +0200)
committerZorro Lang <zlang@kernel.org>
Fri, 20 Jun 2025 16:46:47 +0000 (00:46 +0800)
commit3893dd152f1c915d711bb24bffbc685a3ba06747
tree6aedbb040596871c3fad776526fa55926f0dd091
parent5b6072bc96a4e7948919ad4f93f6e2b970577384
src/fill2: fix segfault during fopen error cleanup

When fill2 fails to open the output file (e.g. due to ENOSPC), it jumps
into the cleanup code where it attempts to call fclose, and this causes
a segfault within the glibc fclose code as it attempts to deref a null
pointer.

Fix it by conditionally calling fclose on the file pointer only when
non-null.

This is consistently reproducible with xfs/041.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/fill2.c